/*
 * Copyright 2021-2024 The PySCF Developers. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

__global__
static void GINTfill_int2e_kernel0022(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    double xkxl = xk - bas_x[lsh];
    double ykyl = yk - bas_y[lsh];
    double zkzl = zk - bas_z[lsh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp3 = tmp1 * aij;
            double b01 = b00 + tmp4 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c0px;
            double g_2 = c0px * c0px + b01;
            double g_3 = c0px + xkxl;
            double g_4 = c0px * (c0px + xkxl) + b01;
            double g_5 = c0px * (2 * b01 + g_2) + xkxl * g_2;
            double g_6 = xkxl * (xkxl + c0px) + xkxl * c0px + c0px * c0px + b01;
            double g_7 = xkxl * (xkxl * c0px + c0px * c0px + b01) + xkxl * g_2 + c0px * g_2 + 2 * b01 * c0px;
            double g_8 = xkxl * (xkxl * g_2 + c0px * g_2 + 2 * b01 * c0px) + xkxl * (c0px * g_2 + 2 * b01 * c0px) + c0px * (c0px * g_2 + 2 * b01 * c0px) + 3 * b01 * g_2;
            double g_9 = 1;
            double g_10 = c0py;
            double g_11 = c0py * c0py + b01;
            double g_12 = c0py + ykyl;
            double g_13 = c0py * (c0py + ykyl) + b01;
            double g_14 = c0py * (2 * b01 + g_11) + ykyl * g_11;
            double g_15 = ykyl * (ykyl + c0py) + ykyl * c0py + c0py * c0py + b01;
            double g_16 = ykyl * (ykyl * c0py + c0py * c0py + b01) + ykyl * g_11 + c0py * g_11 + 2 * b01 * c0py;
            double g_17 = ykyl * (ykyl * g_11 + c0py * g_11 + 2 * b01 * c0py) + ykyl * (c0py * g_11 + 2 * b01 * c0py) + c0py * (c0py * g_11 + 2 * b01 * c0py) + 3 * b01 * g_11;
            double g_18 = weight0 * fac;
            double g_19 = c0pz * g_18;
            double g_20 = b01 * g_18 + c0pz * g_19;
            double g_21 = g_18 * (c0pz + zkzl);
            double g_22 = b01 * g_18 + c0pz * g_19 + zkzl * g_19;
            double g_23 = 2 * b01 * g_19 + c0pz * g_20 + zkzl * g_20;
            double g_24 = zkzl * (zkzl * g_18 + c0pz * g_18) + zkzl * g_19 + c0pz * g_19 + b01 * g_18;
            double g_25 = zkzl * (zkzl * g_19 + c0pz * g_19 + b01 * g_18) + zkzl * g_20 + c0pz * g_20 + 2 * b01 * g_19;
            double g_26 = zkzl * (zkzl * g_20 + c0pz * g_20 + 2 * b01 * g_19) + zkzl * (c0pz * g_20 + 2 * b01 * g_19) + c0pz * (c0pz * g_20 + 2 * b01 * g_19) + 3 * b01 * g_20;
            gout0 += g_8 * g_9 * g_18;
            gout1 += g_7 * g_10 * g_18;
            gout2 += g_7 * g_9 * g_19;
            gout3 += g_6 * g_11 * g_18;
            gout4 += g_6 * g_10 * g_19;
            gout5 += g_6 * g_9 * g_20;
            gout6 += g_5 * g_12 * g_18;
            gout7 += g_4 * g_13 * g_18;
            gout8 += g_4 * g_12 * g_19;
            gout9 += g_3 * g_14 * g_18;
            gout10 += g_3 * g_13 * g_19;
            gout11 += g_3 * g_12 * g_20;
            gout12 += g_5 * g_9 * g_21;
            gout13 += g_4 * g_10 * g_21;
            gout14 += g_4 * g_9 * g_22;
            gout15 += g_3 * g_11 * g_21;
            gout16 += g_3 * g_10 * g_22;
            gout17 += g_3 * g_9 * g_23;
            gout18 += g_2 * g_15 * g_18;
            gout19 += g_1 * g_16 * g_18;
            gout20 += g_1 * g_15 * g_19;
            gout21 += g_0 * g_17 * g_18;
            gout22 += g_0 * g_16 * g_19;
            gout23 += g_0 * g_15 * g_20;
            gout24 += g_2 * g_12 * g_21;
            gout25 += g_1 * g_13 * g_21;
            gout26 += g_1 * g_12 * g_22;
            gout27 += g_0 * g_14 * g_21;
            gout28 += g_0 * g_13 * g_22;
            gout29 += g_0 * g_12 * g_23;
            gout30 += g_2 * g_9 * g_24;
            gout31 += g_1 * g_10 * g_24;
            gout32 += g_1 * g_9 * g_25;
            gout33 += g_0 * g_11 * g_24;
            gout34 += g_0 * g_10 * g_25;
            gout35 += g_0 * g_9 * g_26;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    ////eri_ji[0] = gout0;
    eri_ij[1*kstride] = gout1;
    //eri_ji[1*kstride] = gout1;
    eri_ij[2*kstride] = gout2;
    //eri_ji[2*kstride] = gout2;
    eri_ij[3*kstride] = gout3;
    //eri_ji[3*kstride] = gout3;
    eri_ij[4*kstride] = gout4;
    //eri_ji[4*kstride] = gout4;
    eri_ij[5*kstride] = gout5;
    //eri_ji[5*kstride] = gout5;
    eri_ij[1*lstride] = gout6;
    //eri_ji[1*lstride] = gout6;
    eri_ij[1*kstride+1*lstride] = gout7;
    //eri_ji[1*kstride+1*lstride] = gout7;
    eri_ij[2*kstride+1*lstride] = gout8;
    //eri_ji[2*kstride+1*lstride] = gout8;
    eri_ij[3*kstride+1*lstride] = gout9;
    //eri_ji[3*kstride+1*lstride] = gout9;
    eri_ij[4*kstride+1*lstride] = gout10;
    //eri_ji[4*kstride+1*lstride] = gout10;
    eri_ij[5*kstride+1*lstride] = gout11;
    //eri_ji[5*kstride+1*lstride] = gout11;
    eri_ij[2*lstride] = gout12;
    //eri_ji[2*lstride] = gout12;
    eri_ij[1*kstride+2*lstride] = gout13;
    //eri_ji[1*kstride+2*lstride] = gout13;
    eri_ij[2*kstride+2*lstride] = gout14;
    //eri_ji[2*kstride+2*lstride] = gout14;
    eri_ij[3*kstride+2*lstride] = gout15;
    //eri_ji[3*kstride+2*lstride] = gout15;
    eri_ij[4*kstride+2*lstride] = gout16;
    //eri_ji[4*kstride+2*lstride] = gout16;
    eri_ij[5*kstride+2*lstride] = gout17;
    //eri_ji[5*kstride+2*lstride] = gout17;
    eri_ij[3*lstride] = gout18;
    //eri_ji[3*lstride] = gout18;
    eri_ij[1*kstride+3*lstride] = gout19;
    //eri_ji[1*kstride+3*lstride] = gout19;
    eri_ij[2*kstride+3*lstride] = gout20;
    //eri_ji[2*kstride+3*lstride] = gout20;
    eri_ij[3*kstride+3*lstride] = gout21;
    //eri_ji[3*kstride+3*lstride] = gout21;
    eri_ij[4*kstride+3*lstride] = gout22;
    //eri_ji[4*kstride+3*lstride] = gout22;
    eri_ij[5*kstride+3*lstride] = gout23;
    //eri_ji[5*kstride+3*lstride] = gout23;
    eri_ij[4*lstride] = gout24;
    //eri_ji[4*lstride] = gout24;
    eri_ij[1*kstride+4*lstride] = gout25;
    //eri_ji[1*kstride+4*lstride] = gout25;
    eri_ij[2*kstride+4*lstride] = gout26;
    //eri_ji[2*kstride+4*lstride] = gout26;
    eri_ij[3*kstride+4*lstride] = gout27;
    //eri_ji[3*kstride+4*lstride] = gout27;
    eri_ij[4*kstride+4*lstride] = gout28;
    //eri_ji[4*kstride+4*lstride] = gout28;
    eri_ij[5*kstride+4*lstride] = gout29;
    //eri_ji[5*kstride+4*lstride] = gout29;
    eri_ij[5*lstride] = gout30;
    //eri_ji[5*lstride] = gout30;
    eri_ij[1*kstride+5*lstride] = gout31;
    //eri_ji[1*kstride+5*lstride] = gout31;
    eri_ij[2*kstride+5*lstride] = gout32;
    //eri_ji[2*kstride+5*lstride] = gout32;
    eri_ij[3*kstride+5*lstride] = gout33;
    //eri_ji[3*kstride+5*lstride] = gout33;
    eri_ij[4*kstride+5*lstride] = gout34;
    //eri_ji[4*kstride+5*lstride] = gout34;
    eri_ij[5*kstride+5*lstride] = gout35;
    //eri_ji[5*kstride+5*lstride] = gout35;
}

__global__
static void GINTfill_int2e_kernel0031(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    double xkxl = xk - bas_x[lsh];
    double ykyl = yk - bas_y[lsh];
    double zkzl = zk - bas_z[lsh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp3 = tmp1 * aij;
            double b01 = b00 + tmp4 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c0px;
            double g_2 = c0px * c0px + b01;
            double g_3 = c0px * (2 * b01 + g_2);
            double g_4 = c0px + xkxl;
            double g_5 = c0px * (c0px + xkxl) + b01;
            double g_6 = c0px * (2 * b01 + g_2) + xkxl * g_2;
            double g_7 = 3 * b01 * g_2 + c0px * g_3 + xkxl * g_3;
            double g_8 = 1;
            double g_9 = c0py;
            double g_10 = c0py * c0py + b01;
            double g_11 = c0py * (2 * b01 + g_10);
            double g_12 = c0py + ykyl;
            double g_13 = c0py * (c0py + ykyl) + b01;
            double g_14 = c0py * (2 * b01 + g_10) + ykyl * g_10;
            double g_15 = 3 * b01 * g_10 + c0py * g_11 + ykyl * g_11;
            double g_16 = weight0 * fac;
            double g_17 = c0pz * g_16;
            double g_18 = b01 * g_16 + c0pz * g_17;
            double g_19 = 2 * b01 * g_17 + c0pz * g_18;
            double g_20 = g_16 * (c0pz + zkzl);
            double g_21 = b01 * g_16 + c0pz * g_17 + zkzl * g_17;
            double g_22 = 2 * b01 * g_17 + c0pz * g_18 + zkzl * g_18;
            double g_23 = 3 * b01 * g_18 + c0pz * g_19 + zkzl * g_19;
            gout0 += g_7 * g_8 * g_16;
            gout1 += g_6 * g_9 * g_16;
            gout2 += g_6 * g_8 * g_17;
            gout3 += g_5 * g_10 * g_16;
            gout4 += g_5 * g_9 * g_17;
            gout5 += g_5 * g_8 * g_18;
            gout6 += g_4 * g_11 * g_16;
            gout7 += g_4 * g_10 * g_17;
            gout8 += g_4 * g_9 * g_18;
            gout9 += g_4 * g_8 * g_19;
            gout10 += g_3 * g_12 * g_16;
            gout11 += g_2 * g_13 * g_16;
            gout12 += g_2 * g_12 * g_17;
            gout13 += g_1 * g_14 * g_16;
            gout14 += g_1 * g_13 * g_17;
            gout15 += g_1 * g_12 * g_18;
            gout16 += g_0 * g_15 * g_16;
            gout17 += g_0 * g_14 * g_17;
            gout18 += g_0 * g_13 * g_18;
            gout19 += g_0 * g_12 * g_19;
            gout20 += g_3 * g_8 * g_20;
            gout21 += g_2 * g_9 * g_20;
            gout22 += g_2 * g_8 * g_21;
            gout23 += g_1 * g_10 * g_20;
            gout24 += g_1 * g_9 * g_21;
            gout25 += g_1 * g_8 * g_22;
            gout26 += g_0 * g_11 * g_20;
            gout27 += g_0 * g_10 * g_21;
            gout28 += g_0 * g_9 * g_22;
            gout29 += g_0 * g_8 * g_23;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1*kstride] = gout1;
    //eri_ji[1*kstride] = gout1;
    eri_ij[2*kstride] = gout2;
    //eri_ji[2*kstride] = gout2;
    eri_ij[3*kstride] = gout3;
    //eri_ji[3*kstride] = gout3;
    eri_ij[4*kstride] = gout4;
    //eri_ji[4*kstride] = gout4;
    eri_ij[5*kstride] = gout5;
    //eri_ji[5*kstride] = gout5;
    eri_ij[6*kstride] = gout6;
    //eri_ji[6*kstride] = gout6;
    eri_ij[7*kstride] = gout7;
    //eri_ji[7*kstride] = gout7;
    eri_ij[8*kstride] = gout8;
    //eri_ji[8*kstride] = gout8;
    eri_ij[9*kstride] = gout9;
    //eri_ji[9*kstride] = gout9;
    eri_ij[1*lstride] = gout10;
    //eri_ji[1*lstride] = gout10;
    eri_ij[1*kstride+1*lstride] = gout11;
    //eri_ji[1*kstride+1*lstride] = gout11;
    eri_ij[2*kstride+1*lstride] = gout12;
    //eri_ji[2*kstride+1*lstride] = gout12;
    eri_ij[3*kstride+1*lstride] = gout13;
    //eri_ji[3*kstride+1*lstride] = gout13;
    eri_ij[4*kstride+1*lstride] = gout14;
    //eri_ji[4*kstride+1*lstride] = gout14;
    eri_ij[5*kstride+1*lstride] = gout15;
    //eri_ji[5*kstride+1*lstride] = gout15;
    eri_ij[6*kstride+1*lstride] = gout16;
    //eri_ji[6*kstride+1*lstride] = gout16;
    eri_ij[7*kstride+1*lstride] = gout17;
    //eri_ji[7*kstride+1*lstride] = gout17;
    eri_ij[8*kstride+1*lstride] = gout18;
    //eri_ji[8*kstride+1*lstride] = gout18;
    eri_ij[9*kstride+1*lstride] = gout19;
    //eri_ji[9*kstride+1*lstride] = gout19;
    eri_ij[2*lstride] = gout20;
    //eri_ji[2*lstride] = gout20;
    eri_ij[1*kstride+2*lstride] = gout21;
    //eri_ji[1*kstride+2*lstride] = gout21;
    eri_ij[2*kstride+2*lstride] = gout22;
    //eri_ji[2*kstride+2*lstride] = gout22;
    eri_ij[3*kstride+2*lstride] = gout23;
    //eri_ji[3*kstride+2*lstride] = gout23;
    eri_ij[4*kstride+2*lstride] = gout24;
    //eri_ji[4*kstride+2*lstride] = gout24;
    eri_ij[5*kstride+2*lstride] = gout25;
    //eri_ji[5*kstride+2*lstride] = gout25;
    eri_ij[6*kstride+2*lstride] = gout26;
    //eri_ji[6*kstride+2*lstride] = gout26;
    eri_ij[7*kstride+2*lstride] = gout27;
    //eri_ji[7*kstride+2*lstride] = gout27;
    eri_ij[8*kstride+2*lstride] = gout28;
    //eri_ji[8*kstride+2*lstride] = gout28;
    eri_ij[9*kstride+2*lstride] = gout29;
    //eri_ji[9*kstride+2*lstride] = gout29;
}

__global__
static void GINTfill_int2e_kernel0032(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double gout36 = 0;
    double gout37 = 0;
    double gout38 = 0;
    double gout39 = 0;
    double gout40 = 0;
    double gout41 = 0;
    double gout42 = 0;
    double gout43 = 0;
    double gout44 = 0;
    double gout45 = 0;
    double gout46 = 0;
    double gout47 = 0;
    double gout48 = 0;
    double gout49 = 0;
    double gout50 = 0;
    double gout51 = 0;
    double gout52 = 0;
    double gout53 = 0;
    double gout54 = 0;
    double gout55 = 0;
    double gout56 = 0;
    double gout57 = 0;
    double gout58 = 0;
    double gout59 = 0;
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    double xkxl = xk - bas_x[lsh];
    double ykyl = yk - bas_y[lsh];
    double zkzl = zk - bas_z[lsh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp3 = tmp1 * aij;
            double b01 = b00 + tmp4 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c0px;
            double g_2 = c0px * c0px + b01;
            double g_3 = c0px * (2 * b01 + g_2);
            double g_4 = c0px + xkxl;
            double g_5 = c0px * (c0px + xkxl) + b01;
            double g_6 = c0px * (2 * b01 + g_2) + xkxl * g_2;
            double g_7 = 3 * b01 * g_2 + c0px * g_3 + xkxl * g_3;
            double g_8 = xkxl * (xkxl + c0px) + xkxl * c0px + c0px * c0px + b01;
            double g_9 = xkxl * (xkxl * c0px + c0px * c0px + b01) + xkxl * g_2 + c0px * g_2 + 2 * b01 * c0px;
            double g_10 = xkxl * (xkxl * g_2 + c0px * g_2 + 2 * b01 * c0px) + xkxl * g_3 + c0px * g_3 + 3 * b01 * g_2;
            double g_11 = xkxl * (xkxl * g_3 + c0px * g_3 + 3 * b01 * g_2) + xkxl * (c0px * g_3 + 3 * b01 * g_2) + c0px * (c0px * g_3 + 3 * b01 * g_2) + 4 * b01 * g_3;
            double g_12 = 1;
            double g_13 = c0py;
            double g_14 = c0py * c0py + b01;
            double g_15 = c0py * (2 * b01 + g_14);
            double g_16 = c0py + ykyl;
            double g_17 = c0py * (c0py + ykyl) + b01;
            double g_18 = c0py * (2 * b01 + g_14) + ykyl * g_14;
            double g_19 = 3 * b01 * g_14 + c0py * g_15 + ykyl * g_15;
            double g_20 = ykyl * (ykyl + c0py) + ykyl * c0py + c0py * c0py + b01;
            double g_21 = ykyl * (ykyl * c0py + c0py * c0py + b01) + ykyl * g_14 + c0py * g_14 + 2 * b01 * c0py;
            double g_22 = ykyl * (ykyl * g_14 + c0py * g_14 + 2 * b01 * c0py) + ykyl * g_15 + c0py * g_15 + 3 * b01 * g_14;
            double g_23 = ykyl * (ykyl * g_15 + c0py * g_15 + 3 * b01 * g_14) + ykyl * (c0py * g_15 + 3 * b01 * g_14) + c0py * (c0py * g_15 + 3 * b01 * g_14) + 4 * b01 * g_15;
            double g_24 = weight0 * fac;
            double g_25 = c0pz * g_24;
            double g_26 = b01 * g_24 + c0pz * g_25;
            double g_27 = 2 * b01 * g_25 + c0pz * g_26;
            double g_28 = g_24 * (c0pz + zkzl);
            double g_29 = b01 * g_24 + c0pz * g_25 + zkzl * g_25;
            double g_30 = 2 * b01 * g_25 + c0pz * g_26 + zkzl * g_26;
            double g_31 = 3 * b01 * g_26 + c0pz * g_27 + zkzl * g_27;
            double g_32 = zkzl * (zkzl * g_24 + c0pz * g_24) + zkzl * g_25 + c0pz * g_25 + b01 * g_24;
            double g_33 = zkzl * (zkzl * g_25 + c0pz * g_25 + b01 * g_24) + zkzl * g_26 + c0pz * g_26 + 2 * b01 * g_25;
            double g_34 = zkzl * (zkzl * g_26 + c0pz * g_26 + 2 * b01 * g_25) + zkzl * g_27 + c0pz * g_27 + 3 * b01 * g_26;
            double g_35 = zkzl * (zkzl * g_27 + c0pz * g_27 + 3 * b01 * g_26) + zkzl * (c0pz * g_27 + 3 * b01 * g_26) + c0pz * (c0pz * g_27 + 3 * b01 * g_26) + 4 * b01 * g_27;
            gout0 += g_11 * g_12 * g_24;
            gout1 += g_10 * g_13 * g_24;
            gout2 += g_10 * g_12 * g_25;
            gout3 += g_9 * g_14 * g_24;
            gout4 += g_9 * g_13 * g_25;
            gout5 += g_9 * g_12 * g_26;
            gout6 += g_8 * g_15 * g_24;
            gout7 += g_8 * g_14 * g_25;
            gout8 += g_8 * g_13 * g_26;
            gout9 += g_8 * g_12 * g_27;
            gout10 += g_7 * g_16 * g_24;
            gout11 += g_6 * g_17 * g_24;
            gout12 += g_6 * g_16 * g_25;
            gout13 += g_5 * g_18 * g_24;
            gout14 += g_5 * g_17 * g_25;
            gout15 += g_5 * g_16 * g_26;
            gout16 += g_4 * g_19 * g_24;
            gout17 += g_4 * g_18 * g_25;
            gout18 += g_4 * g_17 * g_26;
            gout19 += g_4 * g_16 * g_27;
            gout20 += g_7 * g_12 * g_28;
            gout21 += g_6 * g_13 * g_28;
            gout22 += g_6 * g_12 * g_29;
            gout23 += g_5 * g_14 * g_28;
            gout24 += g_5 * g_13 * g_29;
            gout25 += g_5 * g_12 * g_30;
            gout26 += g_4 * g_15 * g_28;
            gout27 += g_4 * g_14 * g_29;
            gout28 += g_4 * g_13 * g_30;
            gout29 += g_4 * g_12 * g_31;
            gout30 += g_3 * g_20 * g_24;
            gout31 += g_2 * g_21 * g_24;
            gout32 += g_2 * g_20 * g_25;
            gout33 += g_1 * g_22 * g_24;
            gout34 += g_1 * g_21 * g_25;
            gout35 += g_1 * g_20 * g_26;
            gout36 += g_0 * g_23 * g_24;
            gout37 += g_0 * g_22 * g_25;
            gout38 += g_0 * g_21 * g_26;
            gout39 += g_0 * g_20 * g_27;
            gout40 += g_3 * g_16 * g_28;
            gout41 += g_2 * g_17 * g_28;
            gout42 += g_2 * g_16 * g_29;
            gout43 += g_1 * g_18 * g_28;
            gout44 += g_1 * g_17 * g_29;
            gout45 += g_1 * g_16 * g_30;
            gout46 += g_0 * g_19 * g_28;
            gout47 += g_0 * g_18 * g_29;
            gout48 += g_0 * g_17 * g_30;
            gout49 += g_0 * g_16 * g_31;
            gout50 += g_3 * g_12 * g_32;
            gout51 += g_2 * g_13 * g_32;
            gout52 += g_2 * g_12 * g_33;
            gout53 += g_1 * g_14 * g_32;
            gout54 += g_1 * g_13 * g_33;
            gout55 += g_1 * g_12 * g_34;
            gout56 += g_0 * g_15 * g_32;
            gout57 += g_0 * g_14 * g_33;
            gout58 += g_0 * g_13 * g_34;
            gout59 += g_0 * g_12 * g_35;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1*kstride] = gout1;
    //eri_ji[1*kstride] = gout1;
    eri_ij[2*kstride] = gout2;
    //eri_ji[2*kstride] = gout2;
    eri_ij[3*kstride] = gout3;
    //eri_ji[3*kstride] = gout3;
    eri_ij[4*kstride] = gout4;
    //eri_ji[4*kstride] = gout4;
    eri_ij[5*kstride] = gout5;
    //eri_ji[5*kstride] = gout5;
    eri_ij[6*kstride] = gout6;
    //eri_ji[6*kstride] = gout6;
    eri_ij[7*kstride] = gout7;
    //eri_ji[7*kstride] = gout7;
    eri_ij[8*kstride] = gout8;
    //eri_ji[8*kstride] = gout8;
    eri_ij[9*kstride] = gout9;
    //eri_ji[9*kstride] = gout9;
    eri_ij[1*lstride] = gout10;
    //eri_ji[1*lstride] = gout10;
    eri_ij[1*kstride+1*lstride] = gout11;
    //eri_ji[1*kstride+1*lstride] = gout11;
    eri_ij[2*kstride+1*lstride] = gout12;
    //eri_ji[2*kstride+1*lstride] = gout12;
    eri_ij[3*kstride+1*lstride] = gout13;
    //eri_ji[3*kstride+1*lstride] = gout13;
    eri_ij[4*kstride+1*lstride] = gout14;
    //eri_ji[4*kstride+1*lstride] = gout14;
    eri_ij[5*kstride+1*lstride] = gout15;
    //eri_ji[5*kstride+1*lstride] = gout15;
    eri_ij[6*kstride+1*lstride] = gout16;
    //eri_ji[6*kstride+1*lstride] = gout16;
    eri_ij[7*kstride+1*lstride] = gout17;
    //eri_ji[7*kstride+1*lstride] = gout17;
    eri_ij[8*kstride+1*lstride] = gout18;
    //eri_ji[8*kstride+1*lstride] = gout18;
    eri_ij[9*kstride+1*lstride] = gout19;
    //eri_ji[9*kstride+1*lstride] = gout19;
    eri_ij[2*lstride] = gout20;
    //eri_ji[2*lstride] = gout20;
    eri_ij[1*kstride+2*lstride] = gout21;
    //eri_ji[1*kstride+2*lstride] = gout21;
    eri_ij[2*kstride+2*lstride] = gout22;
    //eri_ji[2*kstride+2*lstride] = gout22;
    eri_ij[3*kstride+2*lstride] = gout23;
    //eri_ji[3*kstride+2*lstride] = gout23;
    eri_ij[4*kstride+2*lstride] = gout24;
    //eri_ji[4*kstride+2*lstride] = gout24;
    eri_ij[5*kstride+2*lstride] = gout25;
    //eri_ji[5*kstride+2*lstride] = gout25;
    eri_ij[6*kstride+2*lstride] = gout26;
    //eri_ji[6*kstride+2*lstride] = gout26;
    eri_ij[7*kstride+2*lstride] = gout27;
    //eri_ji[7*kstride+2*lstride] = gout27;
    eri_ij[8*kstride+2*lstride] = gout28;
    //eri_ji[8*kstride+2*lstride] = gout28;
    eri_ij[9*kstride+2*lstride] = gout29;
    //eri_ji[9*kstride+2*lstride] = gout29;
    eri_ij[3*lstride] = gout30;
    //eri_ji[3*lstride] = gout30;
    eri_ij[1*kstride+3*lstride] = gout31;
    //eri_ji[1*kstride+3*lstride] = gout31;
    eri_ij[2*kstride+3*lstride] = gout32;
    //eri_ji[2*kstride+3*lstride] = gout32;
    eri_ij[3*kstride+3*lstride] = gout33;
    //eri_ji[3*kstride+3*lstride] = gout33;
    eri_ij[4*kstride+3*lstride] = gout34;
    //eri_ji[4*kstride+3*lstride] = gout34;
    eri_ij[5*kstride+3*lstride] = gout35;
    //eri_ji[5*kstride+3*lstride] = gout35;
    eri_ij[6*kstride+3*lstride] = gout36;
    //eri_ji[6*kstride+3*lstride] = gout36;
    eri_ij[7*kstride+3*lstride] = gout37;
    //eri_ji[7*kstride+3*lstride] = gout37;
    eri_ij[8*kstride+3*lstride] = gout38;
    //eri_ji[8*kstride+3*lstride] = gout38;
    eri_ij[9*kstride+3*lstride] = gout39;
    //eri_ji[9*kstride+3*lstride] = gout39;
    eri_ij[4*lstride] = gout40;
    //eri_ji[4*lstride] = gout40;
    eri_ij[1*kstride+4*lstride] = gout41;
    //eri_ji[1*kstride+4*lstride] = gout41;
    eri_ij[2*kstride+4*lstride] = gout42;
    //eri_ji[2*kstride+4*lstride] = gout42;
    eri_ij[3*kstride+4*lstride] = gout43;
    //eri_ji[3*kstride+4*lstride] = gout43;
    eri_ij[4*kstride+4*lstride] = gout44;
    //eri_ji[4*kstride+4*lstride] = gout44;
    eri_ij[5*kstride+4*lstride] = gout45;
    //eri_ji[5*kstride+4*lstride] = gout45;
    eri_ij[6*kstride+4*lstride] = gout46;
    //eri_ji[6*kstride+4*lstride] = gout46;
    eri_ij[7*kstride+4*lstride] = gout47;
    //eri_ji[7*kstride+4*lstride] = gout47;
    eri_ij[8*kstride+4*lstride] = gout48;
    //eri_ji[8*kstride+4*lstride] = gout48;
    eri_ij[9*kstride+4*lstride] = gout49;
    //eri_ji[9*kstride+4*lstride] = gout49;
    eri_ij[5*lstride] = gout50;
    //eri_ji[5*lstride] = gout50;
    eri_ij[1*kstride+5*lstride] = gout51;
    //eri_ji[1*kstride+5*lstride] = gout51;
    eri_ij[2*kstride+5*lstride] = gout52;
    //eri_ji[2*kstride+5*lstride] = gout52;
    eri_ij[3*kstride+5*lstride] = gout53;
    //eri_ji[3*kstride+5*lstride] = gout53;
    eri_ij[4*kstride+5*lstride] = gout54;
    //eri_ji[4*kstride+5*lstride] = gout54;
    eri_ij[5*kstride+5*lstride] = gout55;
    //eri_ji[5*kstride+5*lstride] = gout55;
    eri_ij[6*kstride+5*lstride] = gout56;
    //eri_ji[6*kstride+5*lstride] = gout56;
    eri_ij[7*kstride+5*lstride] = gout57;
    //eri_ji[7*kstride+5*lstride] = gout57;
    eri_ij[8*kstride+5*lstride] = gout58;
    //eri_ji[8*kstride+5*lstride] = gout58;
    eri_ij[9*kstride+5*lstride] = gout59;
    //eri_ji[9*kstride+5*lstride] = gout59;
}

__global__
static void GINTfill_int2e_kernel1021(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double gout36 = 0;
    double gout37 = 0;
    double gout38 = 0;
    double gout39 = 0;
    double gout40 = 0;
    double gout41 = 0;
    double gout42 = 0;
    double gout43 = 0;
    double gout44 = 0;
    double gout45 = 0;
    double gout46 = 0;
    double gout47 = 0;
    double gout48 = 0;
    double gout49 = 0;
    double gout50 = 0;
    double gout51 = 0;
    double gout52 = 0;
    double gout53 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    double xkxl = xk - bas_x[lsh];
    double ykyl = yk - bas_y[lsh];
    double zkzl = zk - bas_z[lsh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double b01 = b00 + tmp4 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c0px;
            double g_3 = c0px * c00x + b00;
            double g_4 = c0px * c0px + b01;
            double g_5 = b00 * c0px + b01 * c00x + c0px * g_3;
            double g_6 = c0px + xkxl;
            double g_7 = c00x * (c0px + xkxl) + b00;
            double g_8 = c0px * (c0px + xkxl) + b01;
            double g_9 = b00 * c0px + b01 * c00x + c0px * g_3 + xkxl * g_3;
            double g_10 = c0px * (2 * b01 + g_4) + xkxl * g_4;
            double g_11 = 2 * b01 * g_3 + b00 * g_4 + c0px * g_5 + xkxl * g_5;
            double g_12 = 1;
            double g_13 = c00y;
            double g_14 = c0py;
            double g_15 = c0py * c00y + b00;
            double g_16 = c0py * c0py + b01;
            double g_17 = b00 * c0py + b01 * c00y + c0py * g_15;
            double g_18 = c0py + ykyl;
            double g_19 = c00y * (c0py + ykyl) + b00;
            double g_20 = c0py * (c0py + ykyl) + b01;
            double g_21 = b00 * c0py + b01 * c00y + c0py * g_15 + ykyl * g_15;
            double g_22 = c0py * (2 * b01 + g_16) + ykyl * g_16;
            double g_23 = 2 * b01 * g_15 + b00 * g_16 + c0py * g_17 + ykyl * g_17;
            double g_24 = weight0 * fac;
            double g_25 = c00z * g_24;
            double g_26 = c0pz * g_24;
            double g_27 = b00 * g_24 + c0pz * g_25;
            double g_28 = b01 * g_24 + c0pz * g_26;
            double g_29 = b00 * g_26 + b01 * g_25 + c0pz * g_27;
            double g_30 = g_24 * (c0pz + zkzl);
            double g_31 = b00 * g_24 + c0pz * g_25 + zkzl * g_25;
            double g_32 = b01 * g_24 + c0pz * g_26 + zkzl * g_26;
            double g_33 = b00 * g_26 + b01 * g_25 + c0pz * g_27 + zkzl * g_27;
            double g_34 = 2 * b01 * g_26 + c0pz * g_28 + zkzl * g_28;
            double g_35 = 2 * b01 * g_27 + b00 * g_28 + c0pz * g_29 + zkzl * g_29;
            gout0 += g_11 * g_12 * g_24;
            gout1 += g_10 * g_13 * g_24;
            gout2 += g_10 * g_12 * g_25;
            gout3 += g_9 * g_14 * g_24;
            gout4 += g_8 * g_15 * g_24;
            gout5 += g_8 * g_14 * g_25;
            gout6 += g_9 * g_12 * g_26;
            gout7 += g_8 * g_13 * g_26;
            gout8 += g_8 * g_12 * g_27;
            gout9 += g_7 * g_16 * g_24;
            gout10 += g_6 * g_17 * g_24;
            gout11 += g_6 * g_16 * g_25;
            gout12 += g_7 * g_14 * g_26;
            gout13 += g_6 * g_15 * g_26;
            gout14 += g_6 * g_14 * g_27;
            gout15 += g_7 * g_12 * g_28;
            gout16 += g_6 * g_13 * g_28;
            gout17 += g_6 * g_12 * g_29;
            gout18 += g_5 * g_18 * g_24;
            gout19 += g_4 * g_19 * g_24;
            gout20 += g_4 * g_18 * g_25;
            gout21 += g_3 * g_20 * g_24;
            gout22 += g_2 * g_21 * g_24;
            gout23 += g_2 * g_20 * g_25;
            gout24 += g_3 * g_18 * g_26;
            gout25 += g_2 * g_19 * g_26;
            gout26 += g_2 * g_18 * g_27;
            gout27 += g_1 * g_22 * g_24;
            gout28 += g_0 * g_23 * g_24;
            gout29 += g_0 * g_22 * g_25;
            gout30 += g_1 * g_20 * g_26;
            gout31 += g_0 * g_21 * g_26;
            gout32 += g_0 * g_20 * g_27;
            gout33 += g_1 * g_18 * g_28;
            gout34 += g_0 * g_19 * g_28;
            gout35 += g_0 * g_18 * g_29;
            gout36 += g_5 * g_12 * g_30;
            gout37 += g_4 * g_13 * g_30;
            gout38 += g_4 * g_12 * g_31;
            gout39 += g_3 * g_14 * g_30;
            gout40 += g_2 * g_15 * g_30;
            gout41 += g_2 * g_14 * g_31;
            gout42 += g_3 * g_12 * g_32;
            gout43 += g_2 * g_13 * g_32;
            gout44 += g_2 * g_12 * g_33;
            gout45 += g_1 * g_16 * g_30;
            gout46 += g_0 * g_17 * g_30;
            gout47 += g_0 * g_16 * g_31;
            gout48 += g_1 * g_14 * g_32;
            gout49 += g_0 * g_15 * g_32;
            gout50 += g_0 * g_14 * g_33;
            gout51 += g_1 * g_12 * g_34;
            gout52 += g_0 * g_13 * g_34;
            gout53 += g_0 * g_12 * g_35;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[1*kstride] = gout3;
    //eri_ji[1*kstride] = gout3;
    eri_ij[1+1*kstride] = gout4;
    //eri_ji[1*jstride+1*kstride] = gout4;
    eri_ij[2+1*kstride] = gout5;
    //eri_ji[2*jstride+1*kstride] = gout5;
    eri_ij[2*kstride] = gout6;
    //eri_ji[2*kstride] = gout6;
    eri_ij[1+2*kstride] = gout7;
    //eri_ji[1*jstride+2*kstride] = gout7;
    eri_ij[2+2*kstride] = gout8;
    //eri_ji[2*jstride+2*kstride] = gout8;
    eri_ij[3*kstride] = gout9;
    //eri_ji[3*kstride] = gout9;
    eri_ij[1+3*kstride] = gout10;
    //eri_ji[1*jstride+3*kstride] = gout10;
    eri_ij[2+3*kstride] = gout11;
    //eri_ji[2*jstride+3*kstride] = gout11;
    eri_ij[4*kstride] = gout12;
    //eri_ji[4*kstride] = gout12;
    eri_ij[1+4*kstride] = gout13;
    //eri_ji[1*jstride+4*kstride] = gout13;
    eri_ij[2+4*kstride] = gout14;
    //eri_ji[2*jstride+4*kstride] = gout14;
    eri_ij[5*kstride] = gout15;
    //eri_ji[5*kstride] = gout15;
    eri_ij[1+5*kstride] = gout16;
    //eri_ji[1*jstride+5*kstride] = gout16;
    eri_ij[2+5*kstride] = gout17;
    //eri_ji[2*jstride+5*kstride] = gout17;
    eri_ij[1*lstride] = gout18;
    //eri_ji[1*lstride] = gout18;
    eri_ij[1+1*lstride] = gout19;
    //eri_ji[1*jstride+1*lstride] = gout19;
    eri_ij[2+1*lstride] = gout20;
    //eri_ji[2*jstride+1*lstride] = gout20;
    eri_ij[1*kstride+1*lstride] = gout21;
    //eri_ji[1*kstride+1*lstride] = gout21;
    eri_ij[1+1*kstride+1*lstride] = gout22;
    //eri_ji[1*jstride+1*kstride+1*lstride] = gout22;
    eri_ij[2+1*kstride+1*lstride] = gout23;
    //eri_ji[2*jstride+1*kstride+1*lstride] = gout23;
    eri_ij[2*kstride+1*lstride] = gout24;
    //eri_ji[2*kstride+1*lstride] = gout24;
    eri_ij[1+2*kstride+1*lstride] = gout25;
    //eri_ji[1*jstride+2*kstride+1*lstride] = gout25;
    eri_ij[2+2*kstride+1*lstride] = gout26;
    //eri_ji[2*jstride+2*kstride+1*lstride] = gout26;
    eri_ij[3*kstride+1*lstride] = gout27;
    //eri_ji[3*kstride+1*lstride] = gout27;
    eri_ij[1+3*kstride+1*lstride] = gout28;
    //eri_ji[1*jstride+3*kstride+1*lstride] = gout28;
    eri_ij[2+3*kstride+1*lstride] = gout29;
    //eri_ji[2*jstride+3*kstride+1*lstride] = gout29;
    eri_ij[4*kstride+1*lstride] = gout30;
    //eri_ji[4*kstride+1*lstride] = gout30;
    eri_ij[1+4*kstride+1*lstride] = gout31;
    //eri_ji[1*jstride+4*kstride+1*lstride] = gout31;
    eri_ij[2+4*kstride+1*lstride] = gout32;
    //eri_ji[2*jstride+4*kstride+1*lstride] = gout32;
    eri_ij[5*kstride+1*lstride] = gout33;
    //eri_ji[5*kstride+1*lstride] = gout33;
    eri_ij[1+5*kstride+1*lstride] = gout34;
    //eri_ji[1*jstride+5*kstride+1*lstride] = gout34;
    eri_ij[2+5*kstride+1*lstride] = gout35;
    //eri_ji[2*jstride+5*kstride+1*lstride] = gout35;
    eri_ij[2*lstride] = gout36;
    //eri_ji[2*lstride] = gout36;
    eri_ij[1+2*lstride] = gout37;
    //eri_ji[1*jstride+2*lstride] = gout37;
    eri_ij[2+2*lstride] = gout38;
    //eri_ji[2*jstride+2*lstride] = gout38;
    eri_ij[1*kstride+2*lstride] = gout39;
    //eri_ji[1*kstride+2*lstride] = gout39;
    eri_ij[1+1*kstride+2*lstride] = gout40;
    //eri_ji[1*jstride+1*kstride+2*lstride] = gout40;
    eri_ij[2+1*kstride+2*lstride] = gout41;
    //eri_ji[2*jstride+1*kstride+2*lstride] = gout41;
    eri_ij[2*kstride+2*lstride] = gout42;
    //eri_ji[2*kstride+2*lstride] = gout42;
    eri_ij[1+2*kstride+2*lstride] = gout43;
    //eri_ji[1*jstride+2*kstride+2*lstride] = gout43;
    eri_ij[2+2*kstride+2*lstride] = gout44;
    //eri_ji[2*jstride+2*kstride+2*lstride] = gout44;
    eri_ij[3*kstride+2*lstride] = gout45;
    //eri_ji[3*kstride+2*lstride] = gout45;
    eri_ij[1+3*kstride+2*lstride] = gout46;
    //eri_ji[1*jstride+3*kstride+2*lstride] = gout46;
    eri_ij[2+3*kstride+2*lstride] = gout47;
    //eri_ji[2*jstride+3*kstride+2*lstride] = gout47;
    eri_ij[4*kstride+2*lstride] = gout48;
    //eri_ji[4*kstride+2*lstride] = gout48;
    eri_ij[1+4*kstride+2*lstride] = gout49;
    //eri_ji[1*jstride+4*kstride+2*lstride] = gout49;
    eri_ij[2+4*kstride+2*lstride] = gout50;
    //eri_ji[2*jstride+4*kstride+2*lstride] = gout50;
    eri_ij[5*kstride+2*lstride] = gout51;
    //eri_ji[5*kstride+2*lstride] = gout51;
    eri_ij[1+5*kstride+2*lstride] = gout52;
    //eri_ji[1*jstride+5*kstride+2*lstride] = gout52;
    eri_ij[2+5*kstride+2*lstride] = gout53;
    //eri_ji[2*jstride+5*kstride+2*lstride] = gout53;
}

__global__
static void GINTfill_int2e_kernel1022(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double gout36 = 0;
    double gout37 = 0;
    double gout38 = 0;
    double gout39 = 0;
    double gout40 = 0;
    double gout41 = 0;
    double gout42 = 0;
    double gout43 = 0;
    double gout44 = 0;
    double gout45 = 0;
    double gout46 = 0;
    double gout47 = 0;
    double gout48 = 0;
    double gout49 = 0;
    double gout50 = 0;
    double gout51 = 0;
    double gout52 = 0;
    double gout53 = 0;
    double gout54 = 0;
    double gout55 = 0;
    double gout56 = 0;
    double gout57 = 0;
    double gout58 = 0;
    double gout59 = 0;
    double gout60 = 0;
    double gout61 = 0;
    double gout62 = 0;
    double gout63 = 0;
    double gout64 = 0;
    double gout65 = 0;
    double gout66 = 0;
    double gout67 = 0;
    double gout68 = 0;
    double gout69 = 0;
    double gout70 = 0;
    double gout71 = 0;
    double gout72 = 0;
    double gout73 = 0;
    double gout74 = 0;
    double gout75 = 0;
    double gout76 = 0;
    double gout77 = 0;
    double gout78 = 0;
    double gout79 = 0;
    double gout80 = 0;
    double gout81 = 0;
    double gout82 = 0;
    double gout83 = 0;
    double gout84 = 0;
    double gout85 = 0;
    double gout86 = 0;
    double gout87 = 0;
    double gout88 = 0;
    double gout89 = 0;
    double gout90 = 0;
    double gout91 = 0;
    double gout92 = 0;
    double gout93 = 0;
    double gout94 = 0;
    double gout95 = 0;
    double gout96 = 0;
    double gout97 = 0;
    double gout98 = 0;
    double gout99 = 0;
    double gout100 = 0;
    double gout101 = 0;
    double gout102 = 0;
    double gout103 = 0;
    double gout104 = 0;
    double gout105 = 0;
    double gout106 = 0;
    double gout107 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    double xkxl = xk - bas_x[lsh];
    double ykyl = yk - bas_y[lsh];
    double zkzl = zk - bas_z[lsh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double b01 = b00 + tmp4 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c0px;
            double g_3 = c0px * c00x + b00;
            double g_4 = c0px * c0px + b01;
            double g_5 = b00 * c0px + b01 * c00x + c0px * g_3;
            double g_6 = c0px + xkxl;
            double g_7 = c00x * (c0px + xkxl) + b00;
            double g_8 = c0px * (c0px + xkxl) + b01;
            double g_9 = b00 * c0px + b01 * c00x + c0px * g_3 + xkxl * g_3;
            double g_10 = c0px * (2 * b01 + g_4) + xkxl * g_4;
            double g_11 = 2 * b01 * g_3 + b00 * g_4 + c0px * g_5 + xkxl * g_5;
            double g_12 = xkxl * (xkxl + c0px) + xkxl * c0px + c0px * c0px + b01;
            double g_13 = xkxl * (xkxl * c00x + c0px * c00x + b00) + xkxl * g_3 + c0px * g_3 + b01 * c00x + b00 * c0px;
            double g_14 = xkxl * (xkxl * c0px + c0px * c0px + b01) + xkxl * g_4 + c0px * g_4 + 2 * b01 * c0px;
            double g_15 = xkxl * (xkxl * g_3 + c0px * g_3 + b01 * c00x + b00 * c0px) + xkxl * g_5 + c0px * g_5 + 2 * b01 * g_3 + b00 * g_4;
            double g_16 = xkxl * (xkxl * g_4 + c0px * g_4 + 2 * b01 * c0px) + xkxl * (c0px * g_4 + 2 * b01 * c0px) + c0px * (c0px * g_4 + 2 * b01 * c0px) + 3 * b01 * g_4;
            double g_17 = xkxl * (xkxl * g_5 + c0px * g_5 + 2 * b01 * g_3 + b00 * g_4) + xkxl * (c0px * g_5 + 2 * b01 * g_3 + b00 * g_4) + c0px * (c0px * g_5 + 2 * b01 * g_3 + b00 * g_4) + 3 * b01 * g_5 + b00 * (c0px * g_4 + 2 * b01 * c0px);
            double g_18 = 1;
            double g_19 = c00y;
            double g_20 = c0py;
            double g_21 = c0py * c00y + b00;
            double g_22 = c0py * c0py + b01;
            double g_23 = b00 * c0py + b01 * c00y + c0py * g_21;
            double g_24 = c0py + ykyl;
            double g_25 = c00y * (c0py + ykyl) + b00;
            double g_26 = c0py * (c0py + ykyl) + b01;
            double g_27 = b00 * c0py + b01 * c00y + c0py * g_21 + ykyl * g_21;
            double g_28 = c0py * (2 * b01 + g_22) + ykyl * g_22;
            double g_29 = 2 * b01 * g_21 + b00 * g_22 + c0py * g_23 + ykyl * g_23;
            double g_30 = ykyl * (ykyl + c0py) + ykyl * c0py + c0py * c0py + b01;
            double g_31 = ykyl * (ykyl * c00y + c0py * c00y + b00) + ykyl * g_21 + c0py * g_21 + b01 * c00y + b00 * c0py;
            double g_32 = ykyl * (ykyl * c0py + c0py * c0py + b01) + ykyl * g_22 + c0py * g_22 + 2 * b01 * c0py;
            double g_33 = ykyl * (ykyl * g_21 + c0py * g_21 + b01 * c00y + b00 * c0py) + ykyl * g_23 + c0py * g_23 + 2 * b01 * g_21 + b00 * g_22;
            double g_34 = ykyl * (ykyl * g_22 + c0py * g_22 + 2 * b01 * c0py) + ykyl * (c0py * g_22 + 2 * b01 * c0py) + c0py * (c0py * g_22 + 2 * b01 * c0py) + 3 * b01 * g_22;
            double g_35 = ykyl * (ykyl * g_23 + c0py * g_23 + 2 * b01 * g_21 + b00 * g_22) + ykyl * (c0py * g_23 + 2 * b01 * g_21 + b00 * g_22) + c0py * (c0py * g_23 + 2 * b01 * g_21 + b00 * g_22) + 3 * b01 * g_23 + b00 * (c0py * g_22 + 2 * b01 * c0py);
            double g_36 = weight0 * fac;
            double g_37 = c00z * g_36;
            double g_38 = c0pz * g_36;
            double g_39 = b00 * g_36 + c0pz * g_37;
            double g_40 = b01 * g_36 + c0pz * g_38;
            double g_41 = b00 * g_38 + b01 * g_37 + c0pz * g_39;
            double g_42 = g_36 * (c0pz + zkzl);
            double g_43 = b00 * g_36 + c0pz * g_37 + zkzl * g_37;
            double g_44 = b01 * g_36 + c0pz * g_38 + zkzl * g_38;
            double g_45 = b00 * g_38 + b01 * g_37 + c0pz * g_39 + zkzl * g_39;
            double g_46 = 2 * b01 * g_38 + c0pz * g_40 + zkzl * g_40;
            double g_47 = 2 * b01 * g_39 + b00 * g_40 + c0pz * g_41 + zkzl * g_41;
            double g_48 = zkzl * (zkzl * g_36 + c0pz * g_36) + zkzl * g_38 + c0pz * g_38 + b01 * g_36;
            double g_49 = zkzl * (zkzl * g_37 + c0pz * g_37 + b00 * g_36) + zkzl * g_39 + c0pz * g_39 + b01 * g_37 + b00 * g_38;
            double g_50 = zkzl * (zkzl * g_38 + c0pz * g_38 + b01 * g_36) + zkzl * g_40 + c0pz * g_40 + 2 * b01 * g_38;
            double g_51 = zkzl * (zkzl * g_39 + c0pz * g_39 + b01 * g_37 + b00 * g_38) + zkzl * g_41 + c0pz * g_41 + 2 * b01 * g_39 + b00 * g_40;
            double g_52 = zkzl * (zkzl * g_40 + c0pz * g_40 + 2 * b01 * g_38) + zkzl * (c0pz * g_40 + 2 * b01 * g_38) + c0pz * (c0pz * g_40 + 2 * b01 * g_38) + 3 * b01 * g_40;
            double g_53 = zkzl * (zkzl * g_41 + c0pz * g_41 + 2 * b01 * g_39 + b00 * g_40) + zkzl * (c0pz * g_41 + 2 * b01 * g_39 + b00 * g_40) + c0pz * (c0pz * g_41 + 2 * b01 * g_39 + b00 * g_40) + 3 * b01 * g_41 + b00 * (c0pz * g_40 + 2 * b01 * g_38);
            gout0 += g_17 * g_18 * g_36;
            gout1 += g_16 * g_19 * g_36;
            gout2 += g_16 * g_18 * g_37;
            gout3 += g_15 * g_20 * g_36;
            gout4 += g_14 * g_21 * g_36;
            gout5 += g_14 * g_20 * g_37;
            gout6 += g_15 * g_18 * g_38;
            gout7 += g_14 * g_19 * g_38;
            gout8 += g_14 * g_18 * g_39;
            gout9 += g_13 * g_22 * g_36;
            gout10 += g_12 * g_23 * g_36;
            gout11 += g_12 * g_22 * g_37;
            gout12 += g_13 * g_20 * g_38;
            gout13 += g_12 * g_21 * g_38;
            gout14 += g_12 * g_20 * g_39;
            gout15 += g_13 * g_18 * g_40;
            gout16 += g_12 * g_19 * g_40;
            gout17 += g_12 * g_18 * g_41;
            gout18 += g_11 * g_24 * g_36;
            gout19 += g_10 * g_25 * g_36;
            gout20 += g_10 * g_24 * g_37;
            gout21 += g_9 * g_26 * g_36;
            gout22 += g_8 * g_27 * g_36;
            gout23 += g_8 * g_26 * g_37;
            gout24 += g_9 * g_24 * g_38;
            gout25 += g_8 * g_25 * g_38;
            gout26 += g_8 * g_24 * g_39;
            gout27 += g_7 * g_28 * g_36;
            gout28 += g_6 * g_29 * g_36;
            gout29 += g_6 * g_28 * g_37;
            gout30 += g_7 * g_26 * g_38;
            gout31 += g_6 * g_27 * g_38;
            gout32 += g_6 * g_26 * g_39;
            gout33 += g_7 * g_24 * g_40;
            gout34 += g_6 * g_25 * g_40;
            gout35 += g_6 * g_24 * g_41;
            gout36 += g_11 * g_18 * g_42;
            gout37 += g_10 * g_19 * g_42;
            gout38 += g_10 * g_18 * g_43;
            gout39 += g_9 * g_20 * g_42;
            gout40 += g_8 * g_21 * g_42;
            gout41 += g_8 * g_20 * g_43;
            gout42 += g_9 * g_18 * g_44;
            gout43 += g_8 * g_19 * g_44;
            gout44 += g_8 * g_18 * g_45;
            gout45 += g_7 * g_22 * g_42;
            gout46 += g_6 * g_23 * g_42;
            gout47 += g_6 * g_22 * g_43;
            gout48 += g_7 * g_20 * g_44;
            gout49 += g_6 * g_21 * g_44;
            gout50 += g_6 * g_20 * g_45;
            gout51 += g_7 * g_18 * g_46;
            gout52 += g_6 * g_19 * g_46;
            gout53 += g_6 * g_18 * g_47;
            gout54 += g_5 * g_30 * g_36;
            gout55 += g_4 * g_31 * g_36;
            gout56 += g_4 * g_30 * g_37;
            gout57 += g_3 * g_32 * g_36;
            gout58 += g_2 * g_33 * g_36;
            gout59 += g_2 * g_32 * g_37;
            gout60 += g_3 * g_30 * g_38;
            gout61 += g_2 * g_31 * g_38;
            gout62 += g_2 * g_30 * g_39;
            gout63 += g_1 * g_34 * g_36;
            gout64 += g_0 * g_35 * g_36;
            gout65 += g_0 * g_34 * g_37;
            gout66 += g_1 * g_32 * g_38;
            gout67 += g_0 * g_33 * g_38;
            gout68 += g_0 * g_32 * g_39;
            gout69 += g_1 * g_30 * g_40;
            gout70 += g_0 * g_31 * g_40;
            gout71 += g_0 * g_30 * g_41;
            gout72 += g_5 * g_24 * g_42;
            gout73 += g_4 * g_25 * g_42;
            gout74 += g_4 * g_24 * g_43;
            gout75 += g_3 * g_26 * g_42;
            gout76 += g_2 * g_27 * g_42;
            gout77 += g_2 * g_26 * g_43;
            gout78 += g_3 * g_24 * g_44;
            gout79 += g_2 * g_25 * g_44;
            gout80 += g_2 * g_24 * g_45;
            gout81 += g_1 * g_28 * g_42;
            gout82 += g_0 * g_29 * g_42;
            gout83 += g_0 * g_28 * g_43;
            gout84 += g_1 * g_26 * g_44;
            gout85 += g_0 * g_27 * g_44;
            gout86 += g_0 * g_26 * g_45;
            gout87 += g_1 * g_24 * g_46;
            gout88 += g_0 * g_25 * g_46;
            gout89 += g_0 * g_24 * g_47;
            gout90 += g_5 * g_18 * g_48;
            gout91 += g_4 * g_19 * g_48;
            gout92 += g_4 * g_18 * g_49;
            gout93 += g_3 * g_20 * g_48;
            gout94 += g_2 * g_21 * g_48;
            gout95 += g_2 * g_20 * g_49;
            gout96 += g_3 * g_18 * g_50;
            gout97 += g_2 * g_19 * g_50;
            gout98 += g_2 * g_18 * g_51;
            gout99 += g_1 * g_22 * g_48;
            gout100 += g_0 * g_23 * g_48;
            gout101 += g_0 * g_22 * g_49;
            gout102 += g_1 * g_20 * g_50;
            gout103 += g_0 * g_21 * g_50;
            gout104 += g_0 * g_20 * g_51;
            gout105 += g_1 * g_18 * g_52;
            gout106 += g_0 * g_19 * g_52;
            gout107 += g_0 * g_18 * g_53;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[1*kstride] = gout3;
    //eri_ji[1*kstride] = gout3;
    eri_ij[1+1*kstride] = gout4;
    //eri_ji[1*jstride+1*kstride] = gout4;
    eri_ij[2+1*kstride] = gout5;
    //eri_ji[2*jstride+1*kstride] = gout5;
    eri_ij[2*kstride] = gout6;
    //eri_ji[2*kstride] = gout6;
    eri_ij[1+2*kstride] = gout7;
    //eri_ji[1*jstride+2*kstride] = gout7;
    eri_ij[2+2*kstride] = gout8;
    //eri_ji[2*jstride+2*kstride] = gout8;
    eri_ij[3*kstride] = gout9;
    //eri_ji[3*kstride] = gout9;
    eri_ij[1+3*kstride] = gout10;
    //eri_ji[1*jstride+3*kstride] = gout10;
    eri_ij[2+3*kstride] = gout11;
    //eri_ji[2*jstride+3*kstride] = gout11;
    eri_ij[4*kstride] = gout12;
    //eri_ji[4*kstride] = gout12;
    eri_ij[1+4*kstride] = gout13;
    //eri_ji[1*jstride+4*kstride] = gout13;
    eri_ij[2+4*kstride] = gout14;
    //eri_ji[2*jstride+4*kstride] = gout14;
    eri_ij[5*kstride] = gout15;
    //eri_ji[5*kstride] = gout15;
    eri_ij[1+5*kstride] = gout16;
    //eri_ji[1*jstride+5*kstride] = gout16;
    eri_ij[2+5*kstride] = gout17;
    //eri_ji[2*jstride+5*kstride] = gout17;
    eri_ij[1*lstride] = gout18;
    //eri_ji[1*lstride] = gout18;
    eri_ij[1+1*lstride] = gout19;
    //eri_ji[1*jstride+1*lstride] = gout19;
    eri_ij[2+1*lstride] = gout20;
    //eri_ji[2*jstride+1*lstride] = gout20;
    eri_ij[1*kstride+1*lstride] = gout21;
    //eri_ji[1*kstride+1*lstride] = gout21;
    eri_ij[1+1*kstride+1*lstride] = gout22;
    //eri_ji[1*jstride+1*kstride+1*lstride] = gout22;
    eri_ij[2+1*kstride+1*lstride] = gout23;
    //eri_ji[2*jstride+1*kstride+1*lstride] = gout23;
    eri_ij[2*kstride+1*lstride] = gout24;
    //eri_ji[2*kstride+1*lstride] = gout24;
    eri_ij[1+2*kstride+1*lstride] = gout25;
    //eri_ji[1*jstride+2*kstride+1*lstride] = gout25;
    eri_ij[2+2*kstride+1*lstride] = gout26;
    //eri_ji[2*jstride+2*kstride+1*lstride] = gout26;
    eri_ij[3*kstride+1*lstride] = gout27;
    //eri_ji[3*kstride+1*lstride] = gout27;
    eri_ij[1+3*kstride+1*lstride] = gout28;
    //eri_ji[1*jstride+3*kstride+1*lstride] = gout28;
    eri_ij[2+3*kstride+1*lstride] = gout29;
    //eri_ji[2*jstride+3*kstride+1*lstride] = gout29;
    eri_ij[4*kstride+1*lstride] = gout30;
    //eri_ji[4*kstride+1*lstride] = gout30;
    eri_ij[1+4*kstride+1*lstride] = gout31;
    //eri_ji[1*jstride+4*kstride+1*lstride] = gout31;
    eri_ij[2+4*kstride+1*lstride] = gout32;
    //eri_ji[2*jstride+4*kstride+1*lstride] = gout32;
    eri_ij[5*kstride+1*lstride] = gout33;
    //eri_ji[5*kstride+1*lstride] = gout33;
    eri_ij[1+5*kstride+1*lstride] = gout34;
    //eri_ji[1*jstride+5*kstride+1*lstride] = gout34;
    eri_ij[2+5*kstride+1*lstride] = gout35;
    //eri_ji[2*jstride+5*kstride+1*lstride] = gout35;
    eri_ij[2*lstride] = gout36;
    //eri_ji[2*lstride] = gout36;
    eri_ij[1+2*lstride] = gout37;
    //eri_ji[1*jstride+2*lstride] = gout37;
    eri_ij[2+2*lstride] = gout38;
    //eri_ji[2*jstride+2*lstride] = gout38;
    eri_ij[1*kstride+2*lstride] = gout39;
    //eri_ji[1*kstride+2*lstride] = gout39;
    eri_ij[1+1*kstride+2*lstride] = gout40;
    //eri_ji[1*jstride+1*kstride+2*lstride] = gout40;
    eri_ij[2+1*kstride+2*lstride] = gout41;
    //eri_ji[2*jstride+1*kstride+2*lstride] = gout41;
    eri_ij[2*kstride+2*lstride] = gout42;
    //eri_ji[2*kstride+2*lstride] = gout42;
    eri_ij[1+2*kstride+2*lstride] = gout43;
    //eri_ji[1*jstride+2*kstride+2*lstride] = gout43;
    eri_ij[2+2*kstride+2*lstride] = gout44;
    //eri_ji[2*jstride+2*kstride+2*lstride] = gout44;
    eri_ij[3*kstride+2*lstride] = gout45;
    //eri_ji[3*kstride+2*lstride] = gout45;
    eri_ij[1+3*kstride+2*lstride] = gout46;
    //eri_ji[1*jstride+3*kstride+2*lstride] = gout46;
    eri_ij[2+3*kstride+2*lstride] = gout47;
    //eri_ji[2*jstride+3*kstride+2*lstride] = gout47;
    eri_ij[4*kstride+2*lstride] = gout48;
    //eri_ji[4*kstride+2*lstride] = gout48;
    eri_ij[1+4*kstride+2*lstride] = gout49;
    //eri_ji[1*jstride+4*kstride+2*lstride] = gout49;
    eri_ij[2+4*kstride+2*lstride] = gout50;
    //eri_ji[2*jstride+4*kstride+2*lstride] = gout50;
    eri_ij[5*kstride+2*lstride] = gout51;
    //eri_ji[5*kstride+2*lstride] = gout51;
    eri_ij[1+5*kstride+2*lstride] = gout52;
    //eri_ji[1*jstride+5*kstride+2*lstride] = gout52;
    eri_ij[2+5*kstride+2*lstride] = gout53;
    //eri_ji[2*jstride+5*kstride+2*lstride] = gout53;
    eri_ij[3*lstride] = gout54;
    //eri_ji[3*lstride] = gout54;
    eri_ij[1+3*lstride] = gout55;
    //eri_ji[1*jstride+3*lstride] = gout55;
    eri_ij[2+3*lstride] = gout56;
    //eri_ji[2*jstride+3*lstride] = gout56;
    eri_ij[1*kstride+3*lstride] = gout57;
    //eri_ji[1*kstride+3*lstride] = gout57;
    eri_ij[1+1*kstride+3*lstride] = gout58;
    //eri_ji[1*jstride+1*kstride+3*lstride] = gout58;
    eri_ij[2+1*kstride+3*lstride] = gout59;
    //eri_ji[2*jstride+1*kstride+3*lstride] = gout59;
    eri_ij[2*kstride+3*lstride] = gout60;
    //eri_ji[2*kstride+3*lstride] = gout60;
    eri_ij[1+2*kstride+3*lstride] = gout61;
    //eri_ji[1*jstride+2*kstride+3*lstride] = gout61;
    eri_ij[2+2*kstride+3*lstride] = gout62;
    //eri_ji[2*jstride+2*kstride+3*lstride] = gout62;
    eri_ij[3*kstride+3*lstride] = gout63;
    //eri_ji[3*kstride+3*lstride] = gout63;
    eri_ij[1+3*kstride+3*lstride] = gout64;
    //eri_ji[1*jstride+3*kstride+3*lstride] = gout64;
    eri_ij[2+3*kstride+3*lstride] = gout65;
    //eri_ji[2*jstride+3*kstride+3*lstride] = gout65;
    eri_ij[4*kstride+3*lstride] = gout66;
    //eri_ji[4*kstride+3*lstride] = gout66;
    eri_ij[1+4*kstride+3*lstride] = gout67;
    //eri_ji[1*jstride+4*kstride+3*lstride] = gout67;
    eri_ij[2+4*kstride+3*lstride] = gout68;
    //eri_ji[2*jstride+4*kstride+3*lstride] = gout68;
    eri_ij[5*kstride+3*lstride] = gout69;
    //eri_ji[5*kstride+3*lstride] = gout69;
    eri_ij[1+5*kstride+3*lstride] = gout70;
    //eri_ji[1*jstride+5*kstride+3*lstride] = gout70;
    eri_ij[2+5*kstride+3*lstride] = gout71;
    //eri_ji[2*jstride+5*kstride+3*lstride] = gout71;
    eri_ij[4*lstride] = gout72;
    //eri_ji[4*lstride] = gout72;
    eri_ij[1+4*lstride] = gout73;
    //eri_ji[1*jstride+4*lstride] = gout73;
    eri_ij[2+4*lstride] = gout74;
    //eri_ji[2*jstride+4*lstride] = gout74;
    eri_ij[1*kstride+4*lstride] = gout75;
    //eri_ji[1*kstride+4*lstride] = gout75;
    eri_ij[1+1*kstride+4*lstride] = gout76;
    //eri_ji[1*jstride+1*kstride+4*lstride] = gout76;
    eri_ij[2+1*kstride+4*lstride] = gout77;
    //eri_ji[2*jstride+1*kstride+4*lstride] = gout77;
    eri_ij[2*kstride+4*lstride] = gout78;
    //eri_ji[2*kstride+4*lstride] = gout78;
    eri_ij[1+2*kstride+4*lstride] = gout79;
    //eri_ji[1*jstride+2*kstride+4*lstride] = gout79;
    eri_ij[2+2*kstride+4*lstride] = gout80;
    //eri_ji[2*jstride+2*kstride+4*lstride] = gout80;
    eri_ij[3*kstride+4*lstride] = gout81;
    //eri_ji[3*kstride+4*lstride] = gout81;
    eri_ij[1+3*kstride+4*lstride] = gout82;
    //eri_ji[1*jstride+3*kstride+4*lstride] = gout82;
    eri_ij[2+3*kstride+4*lstride] = gout83;
    //eri_ji[2*jstride+3*kstride+4*lstride] = gout83;
    eri_ij[4*kstride+4*lstride] = gout84;
    //eri_ji[4*kstride+4*lstride] = gout84;
    eri_ij[1+4*kstride+4*lstride] = gout85;
    //eri_ji[1*jstride+4*kstride+4*lstride] = gout85;
    eri_ij[2+4*kstride+4*lstride] = gout86;
    //eri_ji[2*jstride+4*kstride+4*lstride] = gout86;
    eri_ij[5*kstride+4*lstride] = gout87;
    //eri_ji[5*kstride+4*lstride] = gout87;
    eri_ij[1+5*kstride+4*lstride] = gout88;
    //eri_ji[1*jstride+5*kstride+4*lstride] = gout88;
    eri_ij[2+5*kstride+4*lstride] = gout89;
    //eri_ji[2*jstride+5*kstride+4*lstride] = gout89;
    eri_ij[5*lstride] = gout90;
    //eri_ji[5*lstride] = gout90;
    eri_ij[1+5*lstride] = gout91;
    //eri_ji[1*jstride+5*lstride] = gout91;
    eri_ij[2+5*lstride] = gout92;
    //eri_ji[2*jstride+5*lstride] = gout92;
    eri_ij[1*kstride+5*lstride] = gout93;
    //eri_ji[1*kstride+5*lstride] = gout93;
    eri_ij[1+1*kstride+5*lstride] = gout94;
    //eri_ji[1*jstride+1*kstride+5*lstride] = gout94;
    eri_ij[2+1*kstride+5*lstride] = gout95;
    //eri_ji[2*jstride+1*kstride+5*lstride] = gout95;
    eri_ij[2*kstride+5*lstride] = gout96;
    //eri_ji[2*kstride+5*lstride] = gout96;
    eri_ij[1+2*kstride+5*lstride] = gout97;
    //eri_ji[1*jstride+2*kstride+5*lstride] = gout97;
    eri_ij[2+2*kstride+5*lstride] = gout98;
    //eri_ji[2*jstride+2*kstride+5*lstride] = gout98;
    eri_ij[3*kstride+5*lstride] = gout99;
    //eri_ji[3*kstride+5*lstride] = gout99;
    eri_ij[1+3*kstride+5*lstride] = gout100;
    //eri_ji[1*jstride+3*kstride+5*lstride] = gout100;
    eri_ij[2+3*kstride+5*lstride] = gout101;
    //eri_ji[2*jstride+3*kstride+5*lstride] = gout101;
    eri_ij[4*kstride+5*lstride] = gout102;
    //eri_ji[4*kstride+5*lstride] = gout102;
    eri_ij[1+4*kstride+5*lstride] = gout103;
    //eri_ji[1*jstride+4*kstride+5*lstride] = gout103;
    eri_ij[2+4*kstride+5*lstride] = gout104;
    //eri_ji[2*jstride+4*kstride+5*lstride] = gout104;
    eri_ij[5*kstride+5*lstride] = gout105;
    //eri_ji[5*kstride+5*lstride] = gout105;
    eri_ij[1+5*kstride+5*lstride] = gout106;
    //eri_ji[1*jstride+5*kstride+5*lstride] = gout106;
    eri_ij[2+5*kstride+5*lstride] = gout107;
    //eri_ji[2*jstride+5*kstride+5*lstride] = gout107;
}

__global__
static void GINTfill_int2e_kernel1030(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double b01 = b00 + tmp4 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c0px;
            double g_3 = c0px * c00x + b00;
            double g_4 = c0px * c0px + b01;
            double g_5 = b00 * c0px + b01 * c00x + c0px * g_3;
            double g_6 = c0px * (2 * b01 + g_4);
            double g_7 = 2 * b01 * g_3 + b00 * g_4 + c0px * g_5;
            double g_8 = 1;
            double g_9 = c00y;
            double g_10 = c0py;
            double g_11 = c0py * c00y + b00;
            double g_12 = c0py * c0py + b01;
            double g_13 = b00 * c0py + b01 * c00y + c0py * g_11;
            double g_14 = c0py * (2 * b01 + g_12);
            double g_15 = 2 * b01 * g_11 + b00 * g_12 + c0py * g_13;
            double g_16 = weight0 * fac;
            double g_17 = c00z * g_16;
            double g_18 = c0pz * g_16;
            double g_19 = b00 * g_16 + c0pz * g_17;
            double g_20 = b01 * g_16 + c0pz * g_18;
            double g_21 = b00 * g_18 + b01 * g_17 + c0pz * g_19;
            double g_22 = 2 * b01 * g_18 + c0pz * g_20;
            double g_23 = 2 * b01 * g_19 + b00 * g_20 + c0pz * g_21;
            gout0 += g_7 * g_8 * g_16;
            gout1 += g_6 * g_9 * g_16;
            gout2 += g_6 * g_8 * g_17;
            gout3 += g_5 * g_10 * g_16;
            gout4 += g_4 * g_11 * g_16;
            gout5 += g_4 * g_10 * g_17;
            gout6 += g_5 * g_8 * g_18;
            gout7 += g_4 * g_9 * g_18;
            gout8 += g_4 * g_8 * g_19;
            gout9 += g_3 * g_12 * g_16;
            gout10 += g_2 * g_13 * g_16;
            gout11 += g_2 * g_12 * g_17;
            gout12 += g_3 * g_10 * g_18;
            gout13 += g_2 * g_11 * g_18;
            gout14 += g_2 * g_10 * g_19;
            gout15 += g_3 * g_8 * g_20;
            gout16 += g_2 * g_9 * g_20;
            gout17 += g_2 * g_8 * g_21;
            gout18 += g_1 * g_14 * g_16;
            gout19 += g_0 * g_15 * g_16;
            gout20 += g_0 * g_14 * g_17;
            gout21 += g_1 * g_12 * g_18;
            gout22 += g_0 * g_13 * g_18;
            gout23 += g_0 * g_12 * g_19;
            gout24 += g_1 * g_10 * g_20;
            gout25 += g_0 * g_11 * g_20;
            gout26 += g_0 * g_10 * g_21;
            gout27 += g_1 * g_8 * g_22;
            gout28 += g_0 * g_9 * g_22;
            gout29 += g_0 * g_8 * g_23;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[1*kstride] = gout3;
    //eri_ji[1*kstride] = gout3;
    eri_ij[1+1*kstride] = gout4;
    //eri_ji[1*jstride+1*kstride] = gout4;
    eri_ij[2+1*kstride] = gout5;
    //eri_ji[2*jstride+1*kstride] = gout5;
    eri_ij[2*kstride] = gout6;
    //eri_ji[2*kstride] = gout6;
    eri_ij[1+2*kstride] = gout7;
    //eri_ji[1*jstride+2*kstride] = gout7;
    eri_ij[2+2*kstride] = gout8;
    //eri_ji[2*jstride+2*kstride] = gout8;
    eri_ij[3*kstride] = gout9;
    //eri_ji[3*kstride] = gout9;
    eri_ij[1+3*kstride] = gout10;
    //eri_ji[1*jstride+3*kstride] = gout10;
    eri_ij[2+3*kstride] = gout11;
    //eri_ji[2*jstride+3*kstride] = gout11;
    eri_ij[4*kstride] = gout12;
    //eri_ji[4*kstride] = gout12;
    eri_ij[1+4*kstride] = gout13;
    //eri_ji[1*jstride+4*kstride] = gout13;
    eri_ij[2+4*kstride] = gout14;
    //eri_ji[2*jstride+4*kstride] = gout14;
    eri_ij[5*kstride] = gout15;
    //eri_ji[5*kstride] = gout15;
    eri_ij[1+5*kstride] = gout16;
    //eri_ji[1*jstride+5*kstride] = gout16;
    eri_ij[2+5*kstride] = gout17;
    //eri_ji[2*jstride+5*kstride] = gout17;
    eri_ij[6*kstride] = gout18;
    //eri_ji[6*kstride] = gout18;
    eri_ij[1+6*kstride] = gout19;
    //eri_ji[1*jstride+6*kstride] = gout19;
    eri_ij[2+6*kstride] = gout20;
    //eri_ji[2*jstride+6*kstride] = gout20;
    eri_ij[7*kstride] = gout21;
    //eri_ji[7*kstride] = gout21;
    eri_ij[1+7*kstride] = gout22;
    //eri_ji[1*jstride+7*kstride] = gout22;
    eri_ij[2+7*kstride] = gout23;
    //eri_ji[2*jstride+7*kstride] = gout23;
    eri_ij[8*kstride] = gout24;
    //eri_ji[8*kstride] = gout24;
    eri_ij[1+8*kstride] = gout25;
    //eri_ji[1*jstride+8*kstride] = gout25;
    eri_ij[2+8*kstride] = gout26;
    //eri_ji[2*jstride+8*kstride] = gout26;
    eri_ij[9*kstride] = gout27;
    //eri_ji[9*kstride] = gout27;
    eri_ij[1+9*kstride] = gout28;
    //eri_ji[1*jstride+9*kstride] = gout28;
    eri_ij[2+9*kstride] = gout29;
    //eri_ji[2*jstride+9*kstride] = gout29;
}

__global__
static void GINTfill_int2e_kernel1031(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double gout36 = 0;
    double gout37 = 0;
    double gout38 = 0;
    double gout39 = 0;
    double gout40 = 0;
    double gout41 = 0;
    double gout42 = 0;
    double gout43 = 0;
    double gout44 = 0;
    double gout45 = 0;
    double gout46 = 0;
    double gout47 = 0;
    double gout48 = 0;
    double gout49 = 0;
    double gout50 = 0;
    double gout51 = 0;
    double gout52 = 0;
    double gout53 = 0;
    double gout54 = 0;
    double gout55 = 0;
    double gout56 = 0;
    double gout57 = 0;
    double gout58 = 0;
    double gout59 = 0;
    double gout60 = 0;
    double gout61 = 0;
    double gout62 = 0;
    double gout63 = 0;
    double gout64 = 0;
    double gout65 = 0;
    double gout66 = 0;
    double gout67 = 0;
    double gout68 = 0;
    double gout69 = 0;
    double gout70 = 0;
    double gout71 = 0;
    double gout72 = 0;
    double gout73 = 0;
    double gout74 = 0;
    double gout75 = 0;
    double gout76 = 0;
    double gout77 = 0;
    double gout78 = 0;
    double gout79 = 0;
    double gout80 = 0;
    double gout81 = 0;
    double gout82 = 0;
    double gout83 = 0;
    double gout84 = 0;
    double gout85 = 0;
    double gout86 = 0;
    double gout87 = 0;
    double gout88 = 0;
    double gout89 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    double xkxl = xk - bas_x[lsh];
    double ykyl = yk - bas_y[lsh];
    double zkzl = zk - bas_z[lsh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double b01 = b00 + tmp4 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c0px;
            double g_3 = c0px * c00x + b00;
            double g_4 = c0px * c0px + b01;
            double g_5 = b00 * c0px + b01 * c00x + c0px * g_3;
            double g_6 = c0px * (2 * b01 + g_4);
            double g_7 = 2 * b01 * g_3 + b00 * g_4 + c0px * g_5;
            double g_8 = c0px + xkxl;
            double g_9 = c00x * (c0px + xkxl) + b00;
            double g_10 = c0px * (c0px + xkxl) + b01;
            double g_11 = b00 * c0px + b01 * c00x + c0px * g_3 + xkxl * g_3;
            double g_12 = c0px * (2 * b01 + g_4) + xkxl * g_4;
            double g_13 = 2 * b01 * g_3 + b00 * g_4 + c0px * g_5 + xkxl * g_5;
            double g_14 = 3 * b01 * g_4 + c0px * g_6 + xkxl * g_6;
            double g_15 = 3 * b01 * g_5 + b00 * g_6 + c0px * g_7 + xkxl * g_7;
            double g_16 = 1;
            double g_17 = c00y;
            double g_18 = c0py;
            double g_19 = c0py * c00y + b00;
            double g_20 = c0py * c0py + b01;
            double g_21 = b00 * c0py + b01 * c00y + c0py * g_19;
            double g_22 = c0py * (2 * b01 + g_20);
            double g_23 = 2 * b01 * g_19 + b00 * g_20 + c0py * g_21;
            double g_24 = c0py + ykyl;
            double g_25 = c00y * (c0py + ykyl) + b00;
            double g_26 = c0py * (c0py + ykyl) + b01;
            double g_27 = b00 * c0py + b01 * c00y + c0py * g_19 + ykyl * g_19;
            double g_28 = c0py * (2 * b01 + g_20) + ykyl * g_20;
            double g_29 = 2 * b01 * g_19 + b00 * g_20 + c0py * g_21 + ykyl * g_21;
            double g_30 = 3 * b01 * g_20 + c0py * g_22 + ykyl * g_22;
            double g_31 = 3 * b01 * g_21 + b00 * g_22 + c0py * g_23 + ykyl * g_23;
            double g_32 = weight0 * fac;
            double g_33 = c00z * g_32;
            double g_34 = c0pz * g_32;
            double g_35 = b00 * g_32 + c0pz * g_33;
            double g_36 = b01 * g_32 + c0pz * g_34;
            double g_37 = b00 * g_34 + b01 * g_33 + c0pz * g_35;
            double g_38 = 2 * b01 * g_34 + c0pz * g_36;
            double g_39 = 2 * b01 * g_35 + b00 * g_36 + c0pz * g_37;
            double g_40 = g_32 * (c0pz + zkzl);
            double g_41 = b00 * g_32 + c0pz * g_33 + zkzl * g_33;
            double g_42 = b01 * g_32 + c0pz * g_34 + zkzl * g_34;
            double g_43 = b00 * g_34 + b01 * g_33 + c0pz * g_35 + zkzl * g_35;
            double g_44 = 2 * b01 * g_34 + c0pz * g_36 + zkzl * g_36;
            double g_45 = 2 * b01 * g_35 + b00 * g_36 + c0pz * g_37 + zkzl * g_37;
            double g_46 = 3 * b01 * g_36 + c0pz * g_38 + zkzl * g_38;
            double g_47 = 3 * b01 * g_37 + b00 * g_38 + c0pz * g_39 + zkzl * g_39;
            gout0 += g_15 * g_16 * g_32;
            gout1 += g_14 * g_17 * g_32;
            gout2 += g_14 * g_16 * g_33;
            gout3 += g_13 * g_18 * g_32;
            gout4 += g_12 * g_19 * g_32;
            gout5 += g_12 * g_18 * g_33;
            gout6 += g_13 * g_16 * g_34;
            gout7 += g_12 * g_17 * g_34;
            gout8 += g_12 * g_16 * g_35;
            gout9 += g_11 * g_20 * g_32;
            gout10 += g_10 * g_21 * g_32;
            gout11 += g_10 * g_20 * g_33;
            gout12 += g_11 * g_18 * g_34;
            gout13 += g_10 * g_19 * g_34;
            gout14 += g_10 * g_18 * g_35;
            gout15 += g_11 * g_16 * g_36;
            gout16 += g_10 * g_17 * g_36;
            gout17 += g_10 * g_16 * g_37;
            gout18 += g_9 * g_22 * g_32;
            gout19 += g_8 * g_23 * g_32;
            gout20 += g_8 * g_22 * g_33;
            gout21 += g_9 * g_20 * g_34;
            gout22 += g_8 * g_21 * g_34;
            gout23 += g_8 * g_20 * g_35;
            gout24 += g_9 * g_18 * g_36;
            gout25 += g_8 * g_19 * g_36;
            gout26 += g_8 * g_18 * g_37;
            gout27 += g_9 * g_16 * g_38;
            gout28 += g_8 * g_17 * g_38;
            gout29 += g_8 * g_16 * g_39;
            gout30 += g_7 * g_24 * g_32;
            gout31 += g_6 * g_25 * g_32;
            gout32 += g_6 * g_24 * g_33;
            gout33 += g_5 * g_26 * g_32;
            gout34 += g_4 * g_27 * g_32;
            gout35 += g_4 * g_26 * g_33;
            gout36 += g_5 * g_24 * g_34;
            gout37 += g_4 * g_25 * g_34;
            gout38 += g_4 * g_24 * g_35;
            gout39 += g_3 * g_28 * g_32;
            gout40 += g_2 * g_29 * g_32;
            gout41 += g_2 * g_28 * g_33;
            gout42 += g_3 * g_26 * g_34;
            gout43 += g_2 * g_27 * g_34;
            gout44 += g_2 * g_26 * g_35;
            gout45 += g_3 * g_24 * g_36;
            gout46 += g_2 * g_25 * g_36;
            gout47 += g_2 * g_24 * g_37;
            gout48 += g_1 * g_30 * g_32;
            gout49 += g_0 * g_31 * g_32;
            gout50 += g_0 * g_30 * g_33;
            gout51 += g_1 * g_28 * g_34;
            gout52 += g_0 * g_29 * g_34;
            gout53 += g_0 * g_28 * g_35;
            gout54 += g_1 * g_26 * g_36;
            gout55 += g_0 * g_27 * g_36;
            gout56 += g_0 * g_26 * g_37;
            gout57 += g_1 * g_24 * g_38;
            gout58 += g_0 * g_25 * g_38;
            gout59 += g_0 * g_24 * g_39;
            gout60 += g_7 * g_16 * g_40;
            gout61 += g_6 * g_17 * g_40;
            gout62 += g_6 * g_16 * g_41;
            gout63 += g_5 * g_18 * g_40;
            gout64 += g_4 * g_19 * g_40;
            gout65 += g_4 * g_18 * g_41;
            gout66 += g_5 * g_16 * g_42;
            gout67 += g_4 * g_17 * g_42;
            gout68 += g_4 * g_16 * g_43;
            gout69 += g_3 * g_20 * g_40;
            gout70 += g_2 * g_21 * g_40;
            gout71 += g_2 * g_20 * g_41;
            gout72 += g_3 * g_18 * g_42;
            gout73 += g_2 * g_19 * g_42;
            gout74 += g_2 * g_18 * g_43;
            gout75 += g_3 * g_16 * g_44;
            gout76 += g_2 * g_17 * g_44;
            gout77 += g_2 * g_16 * g_45;
            gout78 += g_1 * g_22 * g_40;
            gout79 += g_0 * g_23 * g_40;
            gout80 += g_0 * g_22 * g_41;
            gout81 += g_1 * g_20 * g_42;
            gout82 += g_0 * g_21 * g_42;
            gout83 += g_0 * g_20 * g_43;
            gout84 += g_1 * g_18 * g_44;
            gout85 += g_0 * g_19 * g_44;
            gout86 += g_0 * g_18 * g_45;
            gout87 += g_1 * g_16 * g_46;
            gout88 += g_0 * g_17 * g_46;
            gout89 += g_0 * g_16 * g_47;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[1*kstride] = gout3;
    //eri_ji[1*kstride] = gout3;
    eri_ij[1+1*kstride] = gout4;
    //eri_ji[1*jstride+1*kstride] = gout4;
    eri_ij[2+1*kstride] = gout5;
    //eri_ji[2*jstride+1*kstride] = gout5;
    eri_ij[2*kstride] = gout6;
    //eri_ji[2*kstride] = gout6;
    eri_ij[1+2*kstride] = gout7;
    //eri_ji[1*jstride+2*kstride] = gout7;
    eri_ij[2+2*kstride] = gout8;
    //eri_ji[2*jstride+2*kstride] = gout8;
    eri_ij[3*kstride] = gout9;
    //eri_ji[3*kstride] = gout9;
    eri_ij[1+3*kstride] = gout10;
    //eri_ji[1*jstride+3*kstride] = gout10;
    eri_ij[2+3*kstride] = gout11;
    //eri_ji[2*jstride+3*kstride] = gout11;
    eri_ij[4*kstride] = gout12;
    //eri_ji[4*kstride] = gout12;
    eri_ij[1+4*kstride] = gout13;
    //eri_ji[1*jstride+4*kstride] = gout13;
    eri_ij[2+4*kstride] = gout14;
    //eri_ji[2*jstride+4*kstride] = gout14;
    eri_ij[5*kstride] = gout15;
    //eri_ji[5*kstride] = gout15;
    eri_ij[1+5*kstride] = gout16;
    //eri_ji[1*jstride+5*kstride] = gout16;
    eri_ij[2+5*kstride] = gout17;
    //eri_ji[2*jstride+5*kstride] = gout17;
    eri_ij[6*kstride] = gout18;
    //eri_ji[6*kstride] = gout18;
    eri_ij[1+6*kstride] = gout19;
    //eri_ji[1*jstride+6*kstride] = gout19;
    eri_ij[2+6*kstride] = gout20;
    //eri_ji[2*jstride+6*kstride] = gout20;
    eri_ij[7*kstride] = gout21;
    //eri_ji[7*kstride] = gout21;
    eri_ij[1+7*kstride] = gout22;
    //eri_ji[1*jstride+7*kstride] = gout22;
    eri_ij[2+7*kstride] = gout23;
    //eri_ji[2*jstride+7*kstride] = gout23;
    eri_ij[8*kstride] = gout24;
    //eri_ji[8*kstride] = gout24;
    eri_ij[1+8*kstride] = gout25;
    //eri_ji[1*jstride+8*kstride] = gout25;
    eri_ij[2+8*kstride] = gout26;
    //eri_ji[2*jstride+8*kstride] = gout26;
    eri_ij[9*kstride] = gout27;
    //eri_ji[9*kstride] = gout27;
    eri_ij[1+9*kstride] = gout28;
    //eri_ji[1*jstride+9*kstride] = gout28;
    eri_ij[2+9*kstride] = gout29;
    //eri_ji[2*jstride+9*kstride] = gout29;
    eri_ij[1*lstride] = gout30;
    //eri_ji[1*lstride] = gout30;
    eri_ij[1+1*lstride] = gout31;
    //eri_ji[1*jstride+1*lstride] = gout31;
    eri_ij[2+1*lstride] = gout32;
    //eri_ji[2*jstride+1*lstride] = gout32;
    eri_ij[1*kstride+1*lstride] = gout33;
    //eri_ji[1*kstride+1*lstride] = gout33;
    eri_ij[1+1*kstride+1*lstride] = gout34;
    //eri_ji[1*jstride+1*kstride+1*lstride] = gout34;
    eri_ij[2+1*kstride+1*lstride] = gout35;
    //eri_ji[2*jstride+1*kstride+1*lstride] = gout35;
    eri_ij[2*kstride+1*lstride] = gout36;
    //eri_ji[2*kstride+1*lstride] = gout36;
    eri_ij[1+2*kstride+1*lstride] = gout37;
    //eri_ji[1*jstride+2*kstride+1*lstride] = gout37;
    eri_ij[2+2*kstride+1*lstride] = gout38;
    //eri_ji[2*jstride+2*kstride+1*lstride] = gout38;
    eri_ij[3*kstride+1*lstride] = gout39;
    //eri_ji[3*kstride+1*lstride] = gout39;
    eri_ij[1+3*kstride+1*lstride] = gout40;
    //eri_ji[1*jstride+3*kstride+1*lstride] = gout40;
    eri_ij[2+3*kstride+1*lstride] = gout41;
    //eri_ji[2*jstride+3*kstride+1*lstride] = gout41;
    eri_ij[4*kstride+1*lstride] = gout42;
    //eri_ji[4*kstride+1*lstride] = gout42;
    eri_ij[1+4*kstride+1*lstride] = gout43;
    //eri_ji[1*jstride+4*kstride+1*lstride] = gout43;
    eri_ij[2+4*kstride+1*lstride] = gout44;
    //eri_ji[2*jstride+4*kstride+1*lstride] = gout44;
    eri_ij[5*kstride+1*lstride] = gout45;
    //eri_ji[5*kstride+1*lstride] = gout45;
    eri_ij[1+5*kstride+1*lstride] = gout46;
    //eri_ji[1*jstride+5*kstride+1*lstride] = gout46;
    eri_ij[2+5*kstride+1*lstride] = gout47;
    //eri_ji[2*jstride+5*kstride+1*lstride] = gout47;
    eri_ij[6*kstride+1*lstride] = gout48;
    //eri_ji[6*kstride+1*lstride] = gout48;
    eri_ij[1+6*kstride+1*lstride] = gout49;
    //eri_ji[1*jstride+6*kstride+1*lstride] = gout49;
    eri_ij[2+6*kstride+1*lstride] = gout50;
    //eri_ji[2*jstride+6*kstride+1*lstride] = gout50;
    eri_ij[7*kstride+1*lstride] = gout51;
    //eri_ji[7*kstride+1*lstride] = gout51;
    eri_ij[1+7*kstride+1*lstride] = gout52;
    //eri_ji[1*jstride+7*kstride+1*lstride] = gout52;
    eri_ij[2+7*kstride+1*lstride] = gout53;
    //eri_ji[2*jstride+7*kstride+1*lstride] = gout53;
    eri_ij[8*kstride+1*lstride] = gout54;
    //eri_ji[8*kstride+1*lstride] = gout54;
    eri_ij[1+8*kstride+1*lstride] = gout55;
    //eri_ji[1*jstride+8*kstride+1*lstride] = gout55;
    eri_ij[2+8*kstride+1*lstride] = gout56;
    //eri_ji[2*jstride+8*kstride+1*lstride] = gout56;
    eri_ij[9*kstride+1*lstride] = gout57;
    //eri_ji[9*kstride+1*lstride] = gout57;
    eri_ij[1+9*kstride+1*lstride] = gout58;
    //eri_ji[1*jstride+9*kstride+1*lstride] = gout58;
    eri_ij[2+9*kstride+1*lstride] = gout59;
    //eri_ji[2*jstride+9*kstride+1*lstride] = gout59;
    eri_ij[2*lstride] = gout60;
    //eri_ji[2*lstride] = gout60;
    eri_ij[1+2*lstride] = gout61;
    //eri_ji[1*jstride+2*lstride] = gout61;
    eri_ij[2+2*lstride] = gout62;
    //eri_ji[2*jstride+2*lstride] = gout62;
    eri_ij[1*kstride+2*lstride] = gout63;
    //eri_ji[1*kstride+2*lstride] = gout63;
    eri_ij[1+1*kstride+2*lstride] = gout64;
    //eri_ji[1*jstride+1*kstride+2*lstride] = gout64;
    eri_ij[2+1*kstride+2*lstride] = gout65;
    //eri_ji[2*jstride+1*kstride+2*lstride] = gout65;
    eri_ij[2*kstride+2*lstride] = gout66;
    //eri_ji[2*kstride+2*lstride] = gout66;
    eri_ij[1+2*kstride+2*lstride] = gout67;
    //eri_ji[1*jstride+2*kstride+2*lstride] = gout67;
    eri_ij[2+2*kstride+2*lstride] = gout68;
    //eri_ji[2*jstride+2*kstride+2*lstride] = gout68;
    eri_ij[3*kstride+2*lstride] = gout69;
    //eri_ji[3*kstride+2*lstride] = gout69;
    eri_ij[1+3*kstride+2*lstride] = gout70;
    //eri_ji[1*jstride+3*kstride+2*lstride] = gout70;
    eri_ij[2+3*kstride+2*lstride] = gout71;
    //eri_ji[2*jstride+3*kstride+2*lstride] = gout71;
    eri_ij[4*kstride+2*lstride] = gout72;
    //eri_ji[4*kstride+2*lstride] = gout72;
    eri_ij[1+4*kstride+2*lstride] = gout73;
    //eri_ji[1*jstride+4*kstride+2*lstride] = gout73;
    eri_ij[2+4*kstride+2*lstride] = gout74;
    //eri_ji[2*jstride+4*kstride+2*lstride] = gout74;
    eri_ij[5*kstride+2*lstride] = gout75;
    //eri_ji[5*kstride+2*lstride] = gout75;
    eri_ij[1+5*kstride+2*lstride] = gout76;
    //eri_ji[1*jstride+5*kstride+2*lstride] = gout76;
    eri_ij[2+5*kstride+2*lstride] = gout77;
    //eri_ji[2*jstride+5*kstride+2*lstride] = gout77;
    eri_ij[6*kstride+2*lstride] = gout78;
    //eri_ji[6*kstride+2*lstride] = gout78;
    eri_ij[1+6*kstride+2*lstride] = gout79;
    //eri_ji[1*jstride+6*kstride+2*lstride] = gout79;
    eri_ij[2+6*kstride+2*lstride] = gout80;
    //eri_ji[2*jstride+6*kstride+2*lstride] = gout80;
    eri_ij[7*kstride+2*lstride] = gout81;
    //eri_ji[7*kstride+2*lstride] = gout81;
    eri_ij[1+7*kstride+2*lstride] = gout82;
    //eri_ji[1*jstride+7*kstride+2*lstride] = gout82;
    eri_ij[2+7*kstride+2*lstride] = gout83;
    //eri_ji[2*jstride+7*kstride+2*lstride] = gout83;
    eri_ij[8*kstride+2*lstride] = gout84;
    //eri_ji[8*kstride+2*lstride] = gout84;
    eri_ij[1+8*kstride+2*lstride] = gout85;
    //eri_ji[1*jstride+8*kstride+2*lstride] = gout85;
    eri_ij[2+8*kstride+2*lstride] = gout86;
    //eri_ji[2*jstride+8*kstride+2*lstride] = gout86;
    eri_ij[9*kstride+2*lstride] = gout87;
    //eri_ji[9*kstride+2*lstride] = gout87;
    eri_ij[1+9*kstride+2*lstride] = gout88;
    //eri_ji[1*jstride+9*kstride+2*lstride] = gout88;
    eri_ij[2+9*kstride+2*lstride] = gout89;
    //eri_ji[2*jstride+9*kstride+2*lstride] = gout89;
}

__global__
static void GINTfill_int2e_kernel1111(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double gout36 = 0;
    double gout37 = 0;
    double gout38 = 0;
    double gout39 = 0;
    double gout40 = 0;
    double gout41 = 0;
    double gout42 = 0;
    double gout43 = 0;
    double gout44 = 0;
    double gout45 = 0;
    double gout46 = 0;
    double gout47 = 0;
    double gout48 = 0;
    double gout49 = 0;
    double gout50 = 0;
    double gout51 = 0;
    double gout52 = 0;
    double gout53 = 0;
    double gout54 = 0;
    double gout55 = 0;
    double gout56 = 0;
    double gout57 = 0;
    double gout58 = 0;
    double gout59 = 0;
    double gout60 = 0;
    double gout61 = 0;
    double gout62 = 0;
    double gout63 = 0;
    double gout64 = 0;
    double gout65 = 0;
    double gout66 = 0;
    double gout67 = 0;
    double gout68 = 0;
    double gout69 = 0;
    double gout70 = 0;
    double gout71 = 0;
    double gout72 = 0;
    double gout73 = 0;
    double gout74 = 0;
    double gout75 = 0;
    double gout76 = 0;
    double gout77 = 0;
    double gout78 = 0;
    double gout79 = 0;
    double gout80 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xixj = xi - bas_x[jsh];
    double yiyj = yi - bas_y[jsh];
    double zizj = zi - bas_z[jsh];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    double xkxl = xk - bas_x[lsh];
    double ykyl = yk - bas_y[lsh];
    double zkzl = zk - bas_z[lsh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double b10 = b00 + tmp4 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double b01 = b00 + tmp4 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c00x + xixj;
            double g_3 = c00x * (c00x + xixj) + b10;
            double g_4 = c0px;
            double g_5 = c0px * c00x + b00;
            double g_6 = c0px * (c00x + xixj) + b00;
            double g_7 = b00 * c00x + b10 * c0px + c00x * g_5 + xixj * g_5;
            double g_8 = c0px + xkxl;
            double g_9 = c00x * (c0px + xkxl) + b00;
            double g_10 = xkxl * (xixj + c00x) + xixj * c0px + c0px * c00x + b00;
            double g_11 = xkxl * (xixj * c00x + c00x * c00x + b10) + xixj * g_5 + c00x * g_5 + b10 * c0px + b00 * c00x;
            double g_12 = c0px * (c0px + xkxl) + b01;
            double g_13 = b00 * c0px + b01 * c00x + c0px * g_5 + xkxl * g_5;
            double g_14 = xkxl * (xixj * c0px + c0px * c00x + b00) + xixj * (c0px * c0px + b01) + c0px * g_5 + b01 * c00x + b00 * c0px;
            double g_15 = xkxl * (xixj * g_5 + c00x * g_5 + b10 * c0px + b00 * c00x) + xixj * (c0px * g_5 + b01 * c00x + b00 * c0px) + c00x * (c0px * g_5 + b01 * c00x + b00 * c0px) + b10 * (c0px * c0px + b01) + 2 * b00 * g_5;
            double g_16 = 1;
            double g_17 = c00y;
            double g_18 = c00y + yiyj;
            double g_19 = c00y * (c00y + yiyj) + b10;
            double g_20 = c0py;
            double g_21 = c0py * c00y + b00;
            double g_22 = c0py * (c00y + yiyj) + b00;
            double g_23 = b00 * c00y + b10 * c0py + c00y * g_21 + yiyj * g_21;
            double g_24 = c0py + ykyl;
            double g_25 = c00y * (c0py + ykyl) + b00;
            double g_26 = ykyl * (yiyj + c00y) + yiyj * c0py + c0py * c00y + b00;
            double g_27 = ykyl * (yiyj * c00y + c00y * c00y + b10) + yiyj * g_21 + c00y * g_21 + b10 * c0py + b00 * c00y;
            double g_28 = c0py * (c0py + ykyl) + b01;
            double g_29 = b00 * c0py + b01 * c00y + c0py * g_21 + ykyl * g_21;
            double g_30 = ykyl * (yiyj * c0py + c0py * c00y + b00) + yiyj * (c0py * c0py + b01) + c0py * g_21 + b01 * c00y + b00 * c0py;
            double g_31 = ykyl * (yiyj * g_21 + c00y * g_21 + b10 * c0py + b00 * c00y) + yiyj * (c0py * g_21 + b01 * c00y + b00 * c0py) + c00y * (c0py * g_21 + b01 * c00y + b00 * c0py) + b10 * (c0py * c0py + b01) + 2 * b00 * g_21;
            double g_32 = weight0 * fac;
            double g_33 = c00z * g_32;
            double g_34 = g_32 * (c00z + zizj);
            double g_35 = b10 * g_32 + c00z * g_33 + zizj * g_33;
            double g_36 = c0pz * g_32;
            double g_37 = b00 * g_32 + c0pz * g_33;
            double g_38 = b00 * g_32 + c0pz * g_33 + zizj * g_36;
            double g_39 = b00 * g_33 + b10 * g_36 + c00z * g_37 + zizj * g_37;
            double g_40 = g_32 * (c0pz + zkzl);
            double g_41 = b00 * g_32 + c0pz * g_33 + zkzl * g_33;
            double g_42 = zkzl * (zizj * g_32 + c00z * g_32) + zizj * g_36 + c0pz * g_33 + b00 * g_32;
            double g_43 = zkzl * (zizj * g_33 + c00z * g_33 + b10 * g_32) + zizj * g_37 + c00z * g_37 + b10 * g_36 + b00 * g_33;
            double g_44 = b01 * g_32 + c0pz * g_36 + zkzl * g_36;
            double g_45 = b00 * g_36 + b01 * g_33 + c0pz * g_37 + zkzl * g_37;
            double g_46 = zkzl * (zizj * g_36 + c0pz * g_33 + b00 * g_32) + zizj * (c0pz * g_36 + b01 * g_32) + c0pz * g_37 + b01 * g_33 + b00 * g_36;
            double g_47 = zkzl * (zizj * g_37 + c00z * g_37 + b10 * g_36 + b00 * g_33) + zizj * (c0pz * g_37 + b01 * g_33 + b00 * g_36) + c00z * (c0pz * g_37 + b01 * g_33 + b00 * g_36) + b10 * (c0pz * g_36 + b01 * g_32) + 2 * b00 * g_37;
            gout0 += g_15 * g_16 * g_32;
            gout1 += g_14 * g_17 * g_32;
            gout2 += g_14 * g_16 * g_33;
            gout3 += g_13 * g_18 * g_32;
            gout4 += g_12 * g_19 * g_32;
            gout5 += g_12 * g_18 * g_33;
            gout6 += g_13 * g_16 * g_34;
            gout7 += g_12 * g_17 * g_34;
            gout8 += g_12 * g_16 * g_35;
            gout9 += g_11 * g_20 * g_32;
            gout10 += g_10 * g_21 * g_32;
            gout11 += g_10 * g_20 * g_33;
            gout12 += g_9 * g_22 * g_32;
            gout13 += g_8 * g_23 * g_32;
            gout14 += g_8 * g_22 * g_33;
            gout15 += g_9 * g_20 * g_34;
            gout16 += g_8 * g_21 * g_34;
            gout17 += g_8 * g_20 * g_35;
            gout18 += g_11 * g_16 * g_36;
            gout19 += g_10 * g_17 * g_36;
            gout20 += g_10 * g_16 * g_37;
            gout21 += g_9 * g_18 * g_36;
            gout22 += g_8 * g_19 * g_36;
            gout23 += g_8 * g_18 * g_37;
            gout24 += g_9 * g_16 * g_38;
            gout25 += g_8 * g_17 * g_38;
            gout26 += g_8 * g_16 * g_39;
            gout27 += g_7 * g_24 * g_32;
            gout28 += g_6 * g_25 * g_32;
            gout29 += g_6 * g_24 * g_33;
            gout30 += g_5 * g_26 * g_32;
            gout31 += g_4 * g_27 * g_32;
            gout32 += g_4 * g_26 * g_33;
            gout33 += g_5 * g_24 * g_34;
            gout34 += g_4 * g_25 * g_34;
            gout35 += g_4 * g_24 * g_35;
            gout36 += g_3 * g_28 * g_32;
            gout37 += g_2 * g_29 * g_32;
            gout38 += g_2 * g_28 * g_33;
            gout39 += g_1 * g_30 * g_32;
            gout40 += g_0 * g_31 * g_32;
            gout41 += g_0 * g_30 * g_33;
            gout42 += g_1 * g_28 * g_34;
            gout43 += g_0 * g_29 * g_34;
            gout44 += g_0 * g_28 * g_35;
            gout45 += g_3 * g_24 * g_36;
            gout46 += g_2 * g_25 * g_36;
            gout47 += g_2 * g_24 * g_37;
            gout48 += g_1 * g_26 * g_36;
            gout49 += g_0 * g_27 * g_36;
            gout50 += g_0 * g_26 * g_37;
            gout51 += g_1 * g_24 * g_38;
            gout52 += g_0 * g_25 * g_38;
            gout53 += g_0 * g_24 * g_39;
            gout54 += g_7 * g_16 * g_40;
            gout55 += g_6 * g_17 * g_40;
            gout56 += g_6 * g_16 * g_41;
            gout57 += g_5 * g_18 * g_40;
            gout58 += g_4 * g_19 * g_40;
            gout59 += g_4 * g_18 * g_41;
            gout60 += g_5 * g_16 * g_42;
            gout61 += g_4 * g_17 * g_42;
            gout62 += g_4 * g_16 * g_43;
            gout63 += g_3 * g_20 * g_40;
            gout64 += g_2 * g_21 * g_40;
            gout65 += g_2 * g_20 * g_41;
            gout66 += g_1 * g_22 * g_40;
            gout67 += g_0 * g_23 * g_40;
            gout68 += g_0 * g_22 * g_41;
            gout69 += g_1 * g_20 * g_42;
            gout70 += g_0 * g_21 * g_42;
            gout71 += g_0 * g_20 * g_43;
            gout72 += g_3 * g_16 * g_44;
            gout73 += g_2 * g_17 * g_44;
            gout74 += g_2 * g_16 * g_45;
            gout75 += g_1 * g_18 * g_44;
            gout76 += g_0 * g_19 * g_44;
            gout77 += g_0 * g_18 * g_45;
            gout78 += g_1 * g_16 * g_46;
            gout79 += g_0 * g_17 * g_46;
            gout80 += g_0 * g_16 * g_47;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[1*jstride] = gout3;
    //eri_ji[1] = gout3;
    eri_ij[1+1*jstride] = gout4;
    //eri_ji[1*jstride+1] = gout4;
    eri_ij[2+1*jstride] = gout5;
    //eri_ji[2*jstride+1] = gout5;
    eri_ij[2*jstride] = gout6;
    //eri_ji[2] = gout6;
    eri_ij[1+2*jstride] = gout7;
    //eri_ji[1*jstride+2] = gout7;
    eri_ij[2+2*jstride] = gout8;
    //eri_ji[2*jstride+2] = gout8;
    eri_ij[1*kstride] = gout9;
    //eri_ji[1*kstride] = gout9;
    eri_ij[1+1*kstride] = gout10;
    //eri_ji[1*jstride+1*kstride] = gout10;
    eri_ij[2+1*kstride] = gout11;
    //eri_ji[2*jstride+1*kstride] = gout11;
    eri_ij[1*jstride+1*kstride] = gout12;
    //eri_ji[1+1*kstride] = gout12;
    eri_ij[1+1*jstride+1*kstride] = gout13;
    //eri_ji[1*jstride+1+1*kstride] = gout13;
    eri_ij[2+1*jstride+1*kstride] = gout14;
    //eri_ji[2*jstride+1+1*kstride] = gout14;
    eri_ij[2*jstride+1*kstride] = gout15;
    //eri_ji[2+1*kstride] = gout15;
    eri_ij[1+2*jstride+1*kstride] = gout16;
    //eri_ji[1*jstride+2+1*kstride] = gout16;
    eri_ij[2+2*jstride+1*kstride] = gout17;
    //eri_ji[2*jstride+2+1*kstride] = gout17;
    eri_ij[2*kstride] = gout18;
    //eri_ji[2*kstride] = gout18;
    eri_ij[1+2*kstride] = gout19;
    //eri_ji[1*jstride+2*kstride] = gout19;
    eri_ij[2+2*kstride] = gout20;
    //eri_ji[2*jstride+2*kstride] = gout20;
    eri_ij[1*jstride+2*kstride] = gout21;
    //eri_ji[1+2*kstride] = gout21;
    eri_ij[1+1*jstride+2*kstride] = gout22;
    //eri_ji[1*jstride+1+2*kstride] = gout22;
    eri_ij[2+1*jstride+2*kstride] = gout23;
    //eri_ji[2*jstride+1+2*kstride] = gout23;
    eri_ij[2*jstride+2*kstride] = gout24;
    //eri_ji[2+2*kstride] = gout24;
    eri_ij[1+2*jstride+2*kstride] = gout25;
    //eri_ji[1*jstride+2+2*kstride] = gout25;
    eri_ij[2+2*jstride+2*kstride] = gout26;
    //eri_ji[2*jstride+2+2*kstride] = gout26;
    eri_ij[1*lstride] = gout27;
    //eri_ji[1*lstride] = gout27;
    eri_ij[1+1*lstride] = gout28;
    //eri_ji[1*jstride+1*lstride] = gout28;
    eri_ij[2+1*lstride] = gout29;
    //eri_ji[2*jstride+1*lstride] = gout29;
    eri_ij[1*jstride+1*lstride] = gout30;
    //eri_ji[1+1*lstride] = gout30;
    eri_ij[1+1*jstride+1*lstride] = gout31;
    //eri_ji[1*jstride+1+1*lstride] = gout31;
    eri_ij[2+1*jstride+1*lstride] = gout32;
    //eri_ji[2*jstride+1+1*lstride] = gout32;
    eri_ij[2*jstride+1*lstride] = gout33;
    //eri_ji[2+1*lstride] = gout33;
    eri_ij[1+2*jstride+1*lstride] = gout34;
    //eri_ji[1*jstride+2+1*lstride] = gout34;
    eri_ij[2+2*jstride+1*lstride] = gout35;
    //eri_ji[2*jstride+2+1*lstride] = gout35;
    eri_ij[1*kstride+1*lstride] = gout36;
    //eri_ji[1*kstride+1*lstride] = gout36;
    eri_ij[1+1*kstride+1*lstride] = gout37;
    //eri_ji[1*jstride+1*kstride+1*lstride] = gout37;
    eri_ij[2+1*kstride+1*lstride] = gout38;
    //eri_ji[2*jstride+1*kstride+1*lstride] = gout38;
    eri_ij[1*jstride+1*kstride+1*lstride] = gout39;
    //eri_ji[1+1*kstride+1*lstride] = gout39;
    eri_ij[1+1*jstride+1*kstride+1*lstride] = gout40;
    //eri_ji[1*jstride+1+1*kstride+1*lstride] = gout40;
    eri_ij[2+1*jstride+1*kstride+1*lstride] = gout41;
    //eri_ji[2*jstride+1+1*kstride+1*lstride] = gout41;
    eri_ij[2*jstride+1*kstride+1*lstride] = gout42;
    //eri_ji[2+1*kstride+1*lstride] = gout42;
    eri_ij[1+2*jstride+1*kstride+1*lstride] = gout43;
    //eri_ji[1*jstride+2+1*kstride+1*lstride] = gout43;
    eri_ij[2+2*jstride+1*kstride+1*lstride] = gout44;
    //eri_ji[2*jstride+2+1*kstride+1*lstride] = gout44;
    eri_ij[2*kstride+1*lstride] = gout45;
    //eri_ji[2*kstride+1*lstride] = gout45;
    eri_ij[1+2*kstride+1*lstride] = gout46;
    //eri_ji[1*jstride+2*kstride+1*lstride] = gout46;
    eri_ij[2+2*kstride+1*lstride] = gout47;
    //eri_ji[2*jstride+2*kstride+1*lstride] = gout47;
    eri_ij[1*jstride+2*kstride+1*lstride] = gout48;
    //eri_ji[1+2*kstride+1*lstride] = gout48;
    eri_ij[1+1*jstride+2*kstride+1*lstride] = gout49;
    //eri_ji[1*jstride+1+2*kstride+1*lstride] = gout49;
    eri_ij[2+1*jstride+2*kstride+1*lstride] = gout50;
    //eri_ji[2*jstride+1+2*kstride+1*lstride] = gout50;
    eri_ij[2*jstride+2*kstride+1*lstride] = gout51;
    //eri_ji[2+2*kstride+1*lstride] = gout51;
    eri_ij[1+2*jstride+2*kstride+1*lstride] = gout52;
    //eri_ji[1*jstride+2+2*kstride+1*lstride] = gout52;
    eri_ij[2+2*jstride+2*kstride+1*lstride] = gout53;
    //eri_ji[2*jstride+2+2*kstride+1*lstride] = gout53;
    eri_ij[2*lstride] = gout54;
    //eri_ji[2*lstride] = gout54;
    eri_ij[1+2*lstride] = gout55;
    //eri_ji[1*jstride+2*lstride] = gout55;
    eri_ij[2+2*lstride] = gout56;
    //eri_ji[2*jstride+2*lstride] = gout56;
    eri_ij[1*jstride+2*lstride] = gout57;
    //eri_ji[1+2*lstride] = gout57;
    eri_ij[1+1*jstride+2*lstride] = gout58;
    //eri_ji[1*jstride+1+2*lstride] = gout58;
    eri_ij[2+1*jstride+2*lstride] = gout59;
    //eri_ji[2*jstride+1+2*lstride] = gout59;
    eri_ij[2*jstride+2*lstride] = gout60;
    //eri_ji[2+2*lstride] = gout60;
    eri_ij[1+2*jstride+2*lstride] = gout61;
    //eri_ji[1*jstride+2+2*lstride] = gout61;
    eri_ij[2+2*jstride+2*lstride] = gout62;
    //eri_ji[2*jstride+2+2*lstride] = gout62;
    eri_ij[1*kstride+2*lstride] = gout63;
    //eri_ji[1*kstride+2*lstride] = gout63;
    eri_ij[1+1*kstride+2*lstride] = gout64;
    //eri_ji[1*jstride+1*kstride+2*lstride] = gout64;
    eri_ij[2+1*kstride+2*lstride] = gout65;
    //eri_ji[2*jstride+1*kstride+2*lstride] = gout65;
    eri_ij[1*jstride+1*kstride+2*lstride] = gout66;
    //eri_ji[1+1*kstride+2*lstride] = gout66;
    eri_ij[1+1*jstride+1*kstride+2*lstride] = gout67;
    //eri_ji[1*jstride+1+1*kstride+2*lstride] = gout67;
    eri_ij[2+1*jstride+1*kstride+2*lstride] = gout68;
    //eri_ji[2*jstride+1+1*kstride+2*lstride] = gout68;
    eri_ij[2*jstride+1*kstride+2*lstride] = gout69;
    //eri_ji[2+1*kstride+2*lstride] = gout69;
    eri_ij[1+2*jstride+1*kstride+2*lstride] = gout70;
    //eri_ji[1*jstride+2+1*kstride+2*lstride] = gout70;
    eri_ij[2+2*jstride+1*kstride+2*lstride] = gout71;
    //eri_ji[2*jstride+2+1*kstride+2*lstride] = gout71;
    eri_ij[2*kstride+2*lstride] = gout72;
    //eri_ji[2*kstride+2*lstride] = gout72;
    eri_ij[1+2*kstride+2*lstride] = gout73;
    //eri_ji[1*jstride+2*kstride+2*lstride] = gout73;
    eri_ij[2+2*kstride+2*lstride] = gout74;
    //eri_ji[2*jstride+2*kstride+2*lstride] = gout74;
    eri_ij[1*jstride+2*kstride+2*lstride] = gout75;
    //eri_ji[1+2*kstride+2*lstride] = gout75;
    eri_ij[1+1*jstride+2*kstride+2*lstride] = gout76;
    //eri_ji[1*jstride+1+2*kstride+2*lstride] = gout76;
    eri_ij[2+1*jstride+2*kstride+2*lstride] = gout77;
    //eri_ji[2*jstride+1+2*kstride+2*lstride] = gout77;
    eri_ij[2*jstride+2*kstride+2*lstride] = gout78;
    //eri_ji[2+2*kstride+2*lstride] = gout78;
    eri_ij[1+2*jstride+2*kstride+2*lstride] = gout79;
    //eri_ji[1*jstride+2+2*kstride+2*lstride] = gout79;
    eri_ij[2+2*jstride+2*kstride+2*lstride] = gout80;
    //eri_ji[2*jstride+2+2*kstride+2*lstride] = gout80;
}

__global__
static void GINTfill_int2e_kernel1120(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double gout36 = 0;
    double gout37 = 0;
    double gout38 = 0;
    double gout39 = 0;
    double gout40 = 0;
    double gout41 = 0;
    double gout42 = 0;
    double gout43 = 0;
    double gout44 = 0;
    double gout45 = 0;
    double gout46 = 0;
    double gout47 = 0;
    double gout48 = 0;
    double gout49 = 0;
    double gout50 = 0;
    double gout51 = 0;
    double gout52 = 0;
    double gout53 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xixj = xi - bas_x[jsh];
    double yiyj = yi - bas_y[jsh];
    double zizj = zi - bas_z[jsh];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double b10 = b00 + tmp4 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double b01 = b00 + tmp4 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c00x + xixj;
            double g_3 = c00x * (c00x + xixj) + b10;
            double g_4 = c0px;
            double g_5 = c0px * c00x + b00;
            double g_6 = c0px * (c00x + xixj) + b00;
            double g_7 = b00 * c00x + b10 * c0px + c00x * g_5 + xixj * g_5;
            double g_8 = c0px * c0px + b01;
            double g_9 = b00 * c0px + b01 * c00x + c0px * g_5;
            double g_10 = b00 * c0px + b01 * c00x + c0px * g_5 + xixj * g_8;
            double g_11 = 2 * b00 * g_5 + b10 * g_8 + c00x * g_9 + xixj * g_9;
            double g_12 = 1;
            double g_13 = c00y;
            double g_14 = c00y + yiyj;
            double g_15 = c00y * (c00y + yiyj) + b10;
            double g_16 = c0py;
            double g_17 = c0py * c00y + b00;
            double g_18 = c0py * (c00y + yiyj) + b00;
            double g_19 = b00 * c00y + b10 * c0py + c00y * g_17 + yiyj * g_17;
            double g_20 = c0py * c0py + b01;
            double g_21 = b00 * c0py + b01 * c00y + c0py * g_17;
            double g_22 = b00 * c0py + b01 * c00y + c0py * g_17 + yiyj * g_20;
            double g_23 = 2 * b00 * g_17 + b10 * g_20 + c00y * g_21 + yiyj * g_21;
            double g_24 = weight0 * fac;
            double g_25 = c00z * g_24;
            double g_26 = g_24 * (c00z + zizj);
            double g_27 = b10 * g_24 + c00z * g_25 + zizj * g_25;
            double g_28 = c0pz * g_24;
            double g_29 = b00 * g_24 + c0pz * g_25;
            double g_30 = b00 * g_24 + c0pz * g_25 + zizj * g_28;
            double g_31 = b00 * g_25 + b10 * g_28 + c00z * g_29 + zizj * g_29;
            double g_32 = b01 * g_24 + c0pz * g_28;
            double g_33 = b00 * g_28 + b01 * g_25 + c0pz * g_29;
            double g_34 = b00 * g_28 + b01 * g_25 + c0pz * g_29 + zizj * g_32;
            double g_35 = 2 * b00 * g_29 + b10 * g_32 + c00z * g_33 + zizj * g_33;
            gout0 += g_11 * g_12 * g_24;
            gout1 += g_10 * g_13 * g_24;
            gout2 += g_10 * g_12 * g_25;
            gout3 += g_9 * g_14 * g_24;
            gout4 += g_8 * g_15 * g_24;
            gout5 += g_8 * g_14 * g_25;
            gout6 += g_9 * g_12 * g_26;
            gout7 += g_8 * g_13 * g_26;
            gout8 += g_8 * g_12 * g_27;
            gout9 += g_7 * g_16 * g_24;
            gout10 += g_6 * g_17 * g_24;
            gout11 += g_6 * g_16 * g_25;
            gout12 += g_5 * g_18 * g_24;
            gout13 += g_4 * g_19 * g_24;
            gout14 += g_4 * g_18 * g_25;
            gout15 += g_5 * g_16 * g_26;
            gout16 += g_4 * g_17 * g_26;
            gout17 += g_4 * g_16 * g_27;
            gout18 += g_7 * g_12 * g_28;
            gout19 += g_6 * g_13 * g_28;
            gout20 += g_6 * g_12 * g_29;
            gout21 += g_5 * g_14 * g_28;
            gout22 += g_4 * g_15 * g_28;
            gout23 += g_4 * g_14 * g_29;
            gout24 += g_5 * g_12 * g_30;
            gout25 += g_4 * g_13 * g_30;
            gout26 += g_4 * g_12 * g_31;
            gout27 += g_3 * g_20 * g_24;
            gout28 += g_2 * g_21 * g_24;
            gout29 += g_2 * g_20 * g_25;
            gout30 += g_1 * g_22 * g_24;
            gout31 += g_0 * g_23 * g_24;
            gout32 += g_0 * g_22 * g_25;
            gout33 += g_1 * g_20 * g_26;
            gout34 += g_0 * g_21 * g_26;
            gout35 += g_0 * g_20 * g_27;
            gout36 += g_3 * g_16 * g_28;
            gout37 += g_2 * g_17 * g_28;
            gout38 += g_2 * g_16 * g_29;
            gout39 += g_1 * g_18 * g_28;
            gout40 += g_0 * g_19 * g_28;
            gout41 += g_0 * g_18 * g_29;
            gout42 += g_1 * g_16 * g_30;
            gout43 += g_0 * g_17 * g_30;
            gout44 += g_0 * g_16 * g_31;
            gout45 += g_3 * g_12 * g_32;
            gout46 += g_2 * g_13 * g_32;
            gout47 += g_2 * g_12 * g_33;
            gout48 += g_1 * g_14 * g_32;
            gout49 += g_0 * g_15 * g_32;
            gout50 += g_0 * g_14 * g_33;
            gout51 += g_1 * g_12 * g_34;
            gout52 += g_0 * g_13 * g_34;
            gout53 += g_0 * g_12 * g_35;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[1*jstride] = gout3;
    //eri_ji[1] = gout3;
    eri_ij[1+1*jstride] = gout4;
    //eri_ji[1*jstride+1] = gout4;
    eri_ij[2+1*jstride] = gout5;
    //eri_ji[2*jstride+1] = gout5;
    eri_ij[2*jstride] = gout6;
    //eri_ji[2] = gout6;
    eri_ij[1+2*jstride] = gout7;
    //eri_ji[1*jstride+2] = gout7;
    eri_ij[2+2*jstride] = gout8;
    //eri_ji[2*jstride+2] = gout8;
    eri_ij[1*kstride] = gout9;
    //eri_ji[1*kstride] = gout9;
    eri_ij[1+1*kstride] = gout10;
    //eri_ji[1*jstride+1*kstride] = gout10;
    eri_ij[2+1*kstride] = gout11;
    //eri_ji[2*jstride+1*kstride] = gout11;
    eri_ij[1*jstride+1*kstride] = gout12;
    //eri_ji[1+1*kstride] = gout12;
    eri_ij[1+1*jstride+1*kstride] = gout13;
    //eri_ji[1*jstride+1+1*kstride] = gout13;
    eri_ij[2+1*jstride+1*kstride] = gout14;
    //eri_ji[2*jstride+1+1*kstride] = gout14;
    eri_ij[2*jstride+1*kstride] = gout15;
    //eri_ji[2+1*kstride] = gout15;
    eri_ij[1+2*jstride+1*kstride] = gout16;
    //eri_ji[1*jstride+2+1*kstride] = gout16;
    eri_ij[2+2*jstride+1*kstride] = gout17;
    //eri_ji[2*jstride+2+1*kstride] = gout17;
    eri_ij[2*kstride] = gout18;
    //eri_ji[2*kstride] = gout18;
    eri_ij[1+2*kstride] = gout19;
    //eri_ji[1*jstride+2*kstride] = gout19;
    eri_ij[2+2*kstride] = gout20;
    //eri_ji[2*jstride+2*kstride] = gout20;
    eri_ij[1*jstride+2*kstride] = gout21;
    //eri_ji[1+2*kstride] = gout21;
    eri_ij[1+1*jstride+2*kstride] = gout22;
    //eri_ji[1*jstride+1+2*kstride] = gout22;
    eri_ij[2+1*jstride+2*kstride] = gout23;
    //eri_ji[2*jstride+1+2*kstride] = gout23;
    eri_ij[2*jstride+2*kstride] = gout24;
    //eri_ji[2+2*kstride] = gout24;
    eri_ij[1+2*jstride+2*kstride] = gout25;
    //eri_ji[1*jstride+2+2*kstride] = gout25;
    eri_ij[2+2*jstride+2*kstride] = gout26;
    //eri_ji[2*jstride+2+2*kstride] = gout26;
    eri_ij[3*kstride] = gout27;
    //eri_ji[3*kstride] = gout27;
    eri_ij[1+3*kstride] = gout28;
    //eri_ji[1*jstride+3*kstride] = gout28;
    eri_ij[2+3*kstride] = gout29;
    //eri_ji[2*jstride+3*kstride] = gout29;
    eri_ij[1*jstride+3*kstride] = gout30;
    //eri_ji[1+3*kstride] = gout30;
    eri_ij[1+1*jstride+3*kstride] = gout31;
    //eri_ji[1*jstride+1+3*kstride] = gout31;
    eri_ij[2+1*jstride+3*kstride] = gout32;
    //eri_ji[2*jstride+1+3*kstride] = gout32;
    eri_ij[2*jstride+3*kstride] = gout33;
    //eri_ji[2+3*kstride] = gout33;
    eri_ij[1+2*jstride+3*kstride] = gout34;
    //eri_ji[1*jstride+2+3*kstride] = gout34;
    eri_ij[2+2*jstride+3*kstride] = gout35;
    //eri_ji[2*jstride+2+3*kstride] = gout35;
    eri_ij[4*kstride] = gout36;
    //eri_ji[4*kstride] = gout36;
    eri_ij[1+4*kstride] = gout37;
    //eri_ji[1*jstride+4*kstride] = gout37;
    eri_ij[2+4*kstride] = gout38;
    //eri_ji[2*jstride+4*kstride] = gout38;
    eri_ij[1*jstride+4*kstride] = gout39;
    //eri_ji[1+4*kstride] = gout39;
    eri_ij[1+1*jstride+4*kstride] = gout40;
    //eri_ji[1*jstride+1+4*kstride] = gout40;
    eri_ij[2+1*jstride+4*kstride] = gout41;
    //eri_ji[2*jstride+1+4*kstride] = gout41;
    eri_ij[2*jstride+4*kstride] = gout42;
    //eri_ji[2+4*kstride] = gout42;
    eri_ij[1+2*jstride+4*kstride] = gout43;
    //eri_ji[1*jstride+2+4*kstride] = gout43;
    eri_ij[2+2*jstride+4*kstride] = gout44;
    //eri_ji[2*jstride+2+4*kstride] = gout44;
    eri_ij[5*kstride] = gout45;
    //eri_ji[5*kstride] = gout45;
    eri_ij[1+5*kstride] = gout46;
    //eri_ji[1*jstride+5*kstride] = gout46;
    eri_ij[2+5*kstride] = gout47;
    //eri_ji[2*jstride+5*kstride] = gout47;
    eri_ij[1*jstride+5*kstride] = gout48;
    //eri_ji[1+5*kstride] = gout48;
    eri_ij[1+1*jstride+5*kstride] = gout49;
    //eri_ji[1*jstride+1+5*kstride] = gout49;
    eri_ij[2+1*jstride+5*kstride] = gout50;
    //eri_ji[2*jstride+1+5*kstride] = gout50;
    eri_ij[2*jstride+5*kstride] = gout51;
    //eri_ji[2+5*kstride] = gout51;
    eri_ij[1+2*jstride+5*kstride] = gout52;
    //eri_ji[1*jstride+2+5*kstride] = gout52;
    eri_ij[2+2*jstride+5*kstride] = gout53;
    //eri_ji[2*jstride+2+5*kstride] = gout53;
}

__global__
static void GINTfill_int2e_kernel1121(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double gout36 = 0;
    double gout37 = 0;
    double gout38 = 0;
    double gout39 = 0;
    double gout40 = 0;
    double gout41 = 0;
    double gout42 = 0;
    double gout43 = 0;
    double gout44 = 0;
    double gout45 = 0;
    double gout46 = 0;
    double gout47 = 0;
    double gout48 = 0;
    double gout49 = 0;
    double gout50 = 0;
    double gout51 = 0;
    double gout52 = 0;
    double gout53 = 0;
    double gout54 = 0;
    double gout55 = 0;
    double gout56 = 0;
    double gout57 = 0;
    double gout58 = 0;
    double gout59 = 0;
    double gout60 = 0;
    double gout61 = 0;
    double gout62 = 0;
    double gout63 = 0;
    double gout64 = 0;
    double gout65 = 0;
    double gout66 = 0;
    double gout67 = 0;
    double gout68 = 0;
    double gout69 = 0;
    double gout70 = 0;
    double gout71 = 0;
    double gout72 = 0;
    double gout73 = 0;
    double gout74 = 0;
    double gout75 = 0;
    double gout76 = 0;
    double gout77 = 0;
    double gout78 = 0;
    double gout79 = 0;
    double gout80 = 0;
    double gout81 = 0;
    double gout82 = 0;
    double gout83 = 0;
    double gout84 = 0;
    double gout85 = 0;
    double gout86 = 0;
    double gout87 = 0;
    double gout88 = 0;
    double gout89 = 0;
    double gout90 = 0;
    double gout91 = 0;
    double gout92 = 0;
    double gout93 = 0;
    double gout94 = 0;
    double gout95 = 0;
    double gout96 = 0;
    double gout97 = 0;
    double gout98 = 0;
    double gout99 = 0;
    double gout100 = 0;
    double gout101 = 0;
    double gout102 = 0;
    double gout103 = 0;
    double gout104 = 0;
    double gout105 = 0;
    double gout106 = 0;
    double gout107 = 0;
    double gout108 = 0;
    double gout109 = 0;
    double gout110 = 0;
    double gout111 = 0;
    double gout112 = 0;
    double gout113 = 0;
    double gout114 = 0;
    double gout115 = 0;
    double gout116 = 0;
    double gout117 = 0;
    double gout118 = 0;
    double gout119 = 0;
    double gout120 = 0;
    double gout121 = 0;
    double gout122 = 0;
    double gout123 = 0;
    double gout124 = 0;
    double gout125 = 0;
    double gout126 = 0;
    double gout127 = 0;
    double gout128 = 0;
    double gout129 = 0;
    double gout130 = 0;
    double gout131 = 0;
    double gout132 = 0;
    double gout133 = 0;
    double gout134 = 0;
    double gout135 = 0;
    double gout136 = 0;
    double gout137 = 0;
    double gout138 = 0;
    double gout139 = 0;
    double gout140 = 0;
    double gout141 = 0;
    double gout142 = 0;
    double gout143 = 0;
    double gout144 = 0;
    double gout145 = 0;
    double gout146 = 0;
    double gout147 = 0;
    double gout148 = 0;
    double gout149 = 0;
    double gout150 = 0;
    double gout151 = 0;
    double gout152 = 0;
    double gout153 = 0;
    double gout154 = 0;
    double gout155 = 0;
    double gout156 = 0;
    double gout157 = 0;
    double gout158 = 0;
    double gout159 = 0;
    double gout160 = 0;
    double gout161 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xixj = xi - bas_x[jsh];
    double yiyj = yi - bas_y[jsh];
    double zizj = zi - bas_z[jsh];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    double xkxl = xk - bas_x[lsh];
    double ykyl = yk - bas_y[lsh];
    double zkzl = zk - bas_z[lsh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double b10 = b00 + tmp4 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double b01 = b00 + tmp4 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c00x + xixj;
            double g_3 = c00x * (c00x + xixj) + b10;
            double g_4 = c0px;
            double g_5 = c0px * c00x + b00;
            double g_6 = c0px * (c00x + xixj) + b00;
            double g_7 = b00 * c00x + b10 * c0px + c00x * g_5 + xixj * g_5;
            double g_8 = c0px * c0px + b01;
            double g_9 = b00 * c0px + b01 * c00x + c0px * g_5;
            double g_10 = b00 * c0px + b01 * c00x + c0px * g_5 + xixj * g_8;
            double g_11 = 2 * b00 * g_5 + b10 * g_8 + c00x * g_9 + xixj * g_9;
            double g_12 = c0px + xkxl;
            double g_13 = c00x * (c0px + xkxl) + b00;
            double g_14 = xkxl * (xixj + c00x) + xixj * c0px + c0px * c00x + b00;
            double g_15 = xkxl * (xixj * c00x + c00x * c00x + b10) + xixj * g_5 + c00x * g_5 + b10 * c0px + b00 * c00x;
            double g_16 = c0px * (c0px + xkxl) + b01;
            double g_17 = b00 * c0px + b01 * c00x + c0px * g_5 + xkxl * g_5;
            double g_18 = xkxl * (xixj * c0px + c0px * c00x + b00) + xixj * g_8 + c0px * g_5 + b01 * c00x + b00 * c0px;
            double g_19 = xkxl * (xixj * g_5 + c00x * g_5 + b10 * c0px + b00 * c00x) + xixj * g_9 + c00x * g_9 + b10 * g_8 + 2 * b00 * g_5;
            double g_20 = c0px * (2 * b01 + g_8) + xkxl * g_8;
            double g_21 = 2 * b01 * g_5 + b00 * g_8 + c0px * g_9 + xkxl * g_9;
            double g_22 = xkxl * (xixj * g_8 + c0px * g_5 + b01 * c00x + b00 * c0px) + xixj * (c0px * g_8 + 2 * b01 * c0px) + c0px * g_9 + 2 * b01 * g_5 + b00 * g_8;
            double g_23 = xkxl * (xixj * g_9 + c00x * g_9 + b10 * g_8 + 2 * b00 * g_5) + xixj * (c0px * g_9 + 2 * b01 * g_5 + b00 * g_8) + c00x * (c0px * g_9 + 2 * b01 * g_5 + b00 * g_8) + b10 * (c0px * g_8 + 2 * b01 * c0px) + 3 * b00 * g_9;
            double g_24 = 1;
            double g_25 = c00y;
            double g_26 = c00y + yiyj;
            double g_27 = c00y * (c00y + yiyj) + b10;
            double g_28 = c0py;
            double g_29 = c0py * c00y + b00;
            double g_30 = c0py * (c00y + yiyj) + b00;
            double g_31 = b00 * c00y + b10 * c0py + c00y * g_29 + yiyj * g_29;
            double g_32 = c0py * c0py + b01;
            double g_33 = b00 * c0py + b01 * c00y + c0py * g_29;
            double g_34 = b00 * c0py + b01 * c00y + c0py * g_29 + yiyj * g_32;
            double g_35 = 2 * b00 * g_29 + b10 * g_32 + c00y * g_33 + yiyj * g_33;
            double g_36 = c0py + ykyl;
            double g_37 = c00y * (c0py + ykyl) + b00;
            double g_38 = ykyl * (yiyj + c00y) + yiyj * c0py + c0py * c00y + b00;
            double g_39 = ykyl * (yiyj * c00y + c00y * c00y + b10) + yiyj * g_29 + c00y * g_29 + b10 * c0py + b00 * c00y;
            double g_40 = c0py * (c0py + ykyl) + b01;
            double g_41 = b00 * c0py + b01 * c00y + c0py * g_29 + ykyl * g_29;
            double g_42 = ykyl * (yiyj * c0py + c0py * c00y + b00) + yiyj * g_32 + c0py * g_29 + b01 * c00y + b00 * c0py;
            double g_43 = ykyl * (yiyj * g_29 + c00y * g_29 + b10 * c0py + b00 * c00y) + yiyj * g_33 + c00y * g_33 + b10 * g_32 + 2 * b00 * g_29;
            double g_44 = c0py * (2 * b01 + g_32) + ykyl * g_32;
            double g_45 = 2 * b01 * g_29 + b00 * g_32 + c0py * g_33 + ykyl * g_33;
            double g_46 = ykyl * (yiyj * g_32 + c0py * g_29 + b01 * c00y + b00 * c0py) + yiyj * (c0py * g_32 + 2 * b01 * c0py) + c0py * g_33 + 2 * b01 * g_29 + b00 * g_32;
            double g_47 = ykyl * (yiyj * g_33 + c00y * g_33 + b10 * g_32 + 2 * b00 * g_29) + yiyj * (c0py * g_33 + 2 * b01 * g_29 + b00 * g_32) + c00y * (c0py * g_33 + 2 * b01 * g_29 + b00 * g_32) + b10 * (c0py * g_32 + 2 * b01 * c0py) + 3 * b00 * g_33;
            double g_48 = weight0 * fac;
            double g_49 = c00z * g_48;
            double g_50 = g_48 * (c00z + zizj);
            double g_51 = b10 * g_48 + c00z * g_49 + zizj * g_49;
            double g_52 = c0pz * g_48;
            double g_53 = b00 * g_48 + c0pz * g_49;
            double g_54 = b00 * g_48 + c0pz * g_49 + zizj * g_52;
            double g_55 = b00 * g_49 + b10 * g_52 + c00z * g_53 + zizj * g_53;
            double g_56 = b01 * g_48 + c0pz * g_52;
            double g_57 = b00 * g_52 + b01 * g_49 + c0pz * g_53;
            double g_58 = b00 * g_52 + b01 * g_49 + c0pz * g_53 + zizj * g_56;
            double g_59 = 2 * b00 * g_53 + b10 * g_56 + c00z * g_57 + zizj * g_57;
            double g_60 = g_48 * (c0pz + zkzl);
            double g_61 = b00 * g_48 + c0pz * g_49 + zkzl * g_49;
            double g_62 = zkzl * (zizj * g_48 + c00z * g_48) + zizj * g_52 + c0pz * g_49 + b00 * g_48;
            double g_63 = zkzl * (zizj * g_49 + c00z * g_49 + b10 * g_48) + zizj * g_53 + c00z * g_53 + b10 * g_52 + b00 * g_49;
            double g_64 = b01 * g_48 + c0pz * g_52 + zkzl * g_52;
            double g_65 = b00 * g_52 + b01 * g_49 + c0pz * g_53 + zkzl * g_53;
            double g_66 = zkzl * (zizj * g_52 + c0pz * g_49 + b00 * g_48) + zizj * g_56 + c0pz * g_53 + b01 * g_49 + b00 * g_52;
            double g_67 = zkzl * (zizj * g_53 + c00z * g_53 + b10 * g_52 + b00 * g_49) + zizj * g_57 + c00z * g_57 + b10 * g_56 + 2 * b00 * g_53;
            double g_68 = 2 * b01 * g_52 + c0pz * g_56 + zkzl * g_56;
            double g_69 = 2 * b01 * g_53 + b00 * g_56 + c0pz * g_57 + zkzl * g_57;
            double g_70 = zkzl * (zizj * g_56 + c0pz * g_53 + b01 * g_49 + b00 * g_52) + zizj * (c0pz * g_56 + 2 * b01 * g_52) + c0pz * g_57 + 2 * b01 * g_53 + b00 * g_56;
            double g_71 = zkzl * (zizj * g_57 + c00z * g_57 + b10 * g_56 + 2 * b00 * g_53) + zizj * (c0pz * g_57 + 2 * b01 * g_53 + b00 * g_56) + c00z * (c0pz * g_57 + 2 * b01 * g_53 + b00 * g_56) + b10 * (c0pz * g_56 + 2 * b01 * g_52) + 3 * b00 * g_57;
            gout0 += g_23 * g_24 * g_48;
            gout1 += g_22 * g_25 * g_48;
            gout2 += g_22 * g_24 * g_49;
            gout3 += g_21 * g_26 * g_48;
            gout4 += g_20 * g_27 * g_48;
            gout5 += g_20 * g_26 * g_49;
            gout6 += g_21 * g_24 * g_50;
            gout7 += g_20 * g_25 * g_50;
            gout8 += g_20 * g_24 * g_51;
            gout9 += g_19 * g_28 * g_48;
            gout10 += g_18 * g_29 * g_48;
            gout11 += g_18 * g_28 * g_49;
            gout12 += g_17 * g_30 * g_48;
            gout13 += g_16 * g_31 * g_48;
            gout14 += g_16 * g_30 * g_49;
            gout15 += g_17 * g_28 * g_50;
            gout16 += g_16 * g_29 * g_50;
            gout17 += g_16 * g_28 * g_51;
            gout18 += g_19 * g_24 * g_52;
            gout19 += g_18 * g_25 * g_52;
            gout20 += g_18 * g_24 * g_53;
            gout21 += g_17 * g_26 * g_52;
            gout22 += g_16 * g_27 * g_52;
            gout23 += g_16 * g_26 * g_53;
            gout24 += g_17 * g_24 * g_54;
            gout25 += g_16 * g_25 * g_54;
            gout26 += g_16 * g_24 * g_55;
            gout27 += g_15 * g_32 * g_48;
            gout28 += g_14 * g_33 * g_48;
            gout29 += g_14 * g_32 * g_49;
            gout30 += g_13 * g_34 * g_48;
            gout31 += g_12 * g_35 * g_48;
            gout32 += g_12 * g_34 * g_49;
            gout33 += g_13 * g_32 * g_50;
            gout34 += g_12 * g_33 * g_50;
            gout35 += g_12 * g_32 * g_51;
            gout36 += g_15 * g_28 * g_52;
            gout37 += g_14 * g_29 * g_52;
            gout38 += g_14 * g_28 * g_53;
            gout39 += g_13 * g_30 * g_52;
            gout40 += g_12 * g_31 * g_52;
            gout41 += g_12 * g_30 * g_53;
            gout42 += g_13 * g_28 * g_54;
            gout43 += g_12 * g_29 * g_54;
            gout44 += g_12 * g_28 * g_55;
            gout45 += g_15 * g_24 * g_56;
            gout46 += g_14 * g_25 * g_56;
            gout47 += g_14 * g_24 * g_57;
            gout48 += g_13 * g_26 * g_56;
            gout49 += g_12 * g_27 * g_56;
            gout50 += g_12 * g_26 * g_57;
            gout51 += g_13 * g_24 * g_58;
            gout52 += g_12 * g_25 * g_58;
            gout53 += g_12 * g_24 * g_59;
            gout54 += g_11 * g_36 * g_48;
            gout55 += g_10 * g_37 * g_48;
            gout56 += g_10 * g_36 * g_49;
            gout57 += g_9 * g_38 * g_48;
            gout58 += g_8 * g_39 * g_48;
            gout59 += g_8 * g_38 * g_49;
            gout60 += g_9 * g_36 * g_50;
            gout61 += g_8 * g_37 * g_50;
            gout62 += g_8 * g_36 * g_51;
            gout63 += g_7 * g_40 * g_48;
            gout64 += g_6 * g_41 * g_48;
            gout65 += g_6 * g_40 * g_49;
            gout66 += g_5 * g_42 * g_48;
            gout67 += g_4 * g_43 * g_48;
            gout68 += g_4 * g_42 * g_49;
            gout69 += g_5 * g_40 * g_50;
            gout70 += g_4 * g_41 * g_50;
            gout71 += g_4 * g_40 * g_51;
            gout72 += g_7 * g_36 * g_52;
            gout73 += g_6 * g_37 * g_52;
            gout74 += g_6 * g_36 * g_53;
            gout75 += g_5 * g_38 * g_52;
            gout76 += g_4 * g_39 * g_52;
            gout77 += g_4 * g_38 * g_53;
            gout78 += g_5 * g_36 * g_54;
            gout79 += g_4 * g_37 * g_54;
            gout80 += g_4 * g_36 * g_55;
            gout81 += g_3 * g_44 * g_48;
            gout82 += g_2 * g_45 * g_48;
            gout83 += g_2 * g_44 * g_49;
            gout84 += g_1 * g_46 * g_48;
            gout85 += g_0 * g_47 * g_48;
            gout86 += g_0 * g_46 * g_49;
            gout87 += g_1 * g_44 * g_50;
            gout88 += g_0 * g_45 * g_50;
            gout89 += g_0 * g_44 * g_51;
            gout90 += g_3 * g_40 * g_52;
            gout91 += g_2 * g_41 * g_52;
            gout92 += g_2 * g_40 * g_53;
            gout93 += g_1 * g_42 * g_52;
            gout94 += g_0 * g_43 * g_52;
            gout95 += g_0 * g_42 * g_53;
            gout96 += g_1 * g_40 * g_54;
            gout97 += g_0 * g_41 * g_54;
            gout98 += g_0 * g_40 * g_55;
            gout99 += g_3 * g_36 * g_56;
            gout100 += g_2 * g_37 * g_56;
            gout101 += g_2 * g_36 * g_57;
            gout102 += g_1 * g_38 * g_56;
            gout103 += g_0 * g_39 * g_56;
            gout104 += g_0 * g_38 * g_57;
            gout105 += g_1 * g_36 * g_58;
            gout106 += g_0 * g_37 * g_58;
            gout107 += g_0 * g_36 * g_59;
            gout108 += g_11 * g_24 * g_60;
            gout109 += g_10 * g_25 * g_60;
            gout110 += g_10 * g_24 * g_61;
            gout111 += g_9 * g_26 * g_60;
            gout112 += g_8 * g_27 * g_60;
            gout113 += g_8 * g_26 * g_61;
            gout114 += g_9 * g_24 * g_62;
            gout115 += g_8 * g_25 * g_62;
            gout116 += g_8 * g_24 * g_63;
            gout117 += g_7 * g_28 * g_60;
            gout118 += g_6 * g_29 * g_60;
            gout119 += g_6 * g_28 * g_61;
            gout120 += g_5 * g_30 * g_60;
            gout121 += g_4 * g_31 * g_60;
            gout122 += g_4 * g_30 * g_61;
            gout123 += g_5 * g_28 * g_62;
            gout124 += g_4 * g_29 * g_62;
            gout125 += g_4 * g_28 * g_63;
            gout126 += g_7 * g_24 * g_64;
            gout127 += g_6 * g_25 * g_64;
            gout128 += g_6 * g_24 * g_65;
            gout129 += g_5 * g_26 * g_64;
            gout130 += g_4 * g_27 * g_64;
            gout131 += g_4 * g_26 * g_65;
            gout132 += g_5 * g_24 * g_66;
            gout133 += g_4 * g_25 * g_66;
            gout134 += g_4 * g_24 * g_67;
            gout135 += g_3 * g_32 * g_60;
            gout136 += g_2 * g_33 * g_60;
            gout137 += g_2 * g_32 * g_61;
            gout138 += g_1 * g_34 * g_60;
            gout139 += g_0 * g_35 * g_60;
            gout140 += g_0 * g_34 * g_61;
            gout141 += g_1 * g_32 * g_62;
            gout142 += g_0 * g_33 * g_62;
            gout143 += g_0 * g_32 * g_63;
            gout144 += g_3 * g_28 * g_64;
            gout145 += g_2 * g_29 * g_64;
            gout146 += g_2 * g_28 * g_65;
            gout147 += g_1 * g_30 * g_64;
            gout148 += g_0 * g_31 * g_64;
            gout149 += g_0 * g_30 * g_65;
            gout150 += g_1 * g_28 * g_66;
            gout151 += g_0 * g_29 * g_66;
            gout152 += g_0 * g_28 * g_67;
            gout153 += g_3 * g_24 * g_68;
            gout154 += g_2 * g_25 * g_68;
            gout155 += g_2 * g_24 * g_69;
            gout156 += g_1 * g_26 * g_68;
            gout157 += g_0 * g_27 * g_68;
            gout158 += g_0 * g_26 * g_69;
            gout159 += g_1 * g_24 * g_70;
            gout160 += g_0 * g_25 * g_70;
            gout161 += g_0 * g_24 * g_71;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[1*jstride] = gout3;
    //eri_ji[1] = gout3;
    eri_ij[1+1*jstride] = gout4;
    //eri_ji[1*jstride+1] = gout4;
    eri_ij[2+1*jstride] = gout5;
    //eri_ji[2*jstride+1] = gout5;
    eri_ij[2*jstride] = gout6;
    //eri_ji[2] = gout6;
    eri_ij[1+2*jstride] = gout7;
    //eri_ji[1*jstride+2] = gout7;
    eri_ij[2+2*jstride] = gout8;
    //eri_ji[2*jstride+2] = gout8;
    eri_ij[1*kstride] = gout9;
    //eri_ji[1*kstride] = gout9;
    eri_ij[1+1*kstride] = gout10;
    //eri_ji[1*jstride+1*kstride] = gout10;
    eri_ij[2+1*kstride] = gout11;
    //eri_ji[2*jstride+1*kstride] = gout11;
    eri_ij[1*jstride+1*kstride] = gout12;
    //eri_ji[1+1*kstride] = gout12;
    eri_ij[1+1*jstride+1*kstride] = gout13;
    //eri_ji[1*jstride+1+1*kstride] = gout13;
    eri_ij[2+1*jstride+1*kstride] = gout14;
    //eri_ji[2*jstride+1+1*kstride] = gout14;
    eri_ij[2*jstride+1*kstride] = gout15;
    //eri_ji[2+1*kstride] = gout15;
    eri_ij[1+2*jstride+1*kstride] = gout16;
    //eri_ji[1*jstride+2+1*kstride] = gout16;
    eri_ij[2+2*jstride+1*kstride] = gout17;
    //eri_ji[2*jstride+2+1*kstride] = gout17;
    eri_ij[2*kstride] = gout18;
    //eri_ji[2*kstride] = gout18;
    eri_ij[1+2*kstride] = gout19;
    //eri_ji[1*jstride+2*kstride] = gout19;
    eri_ij[2+2*kstride] = gout20;
    //eri_ji[2*jstride+2*kstride] = gout20;
    eri_ij[1*jstride+2*kstride] = gout21;
    //eri_ji[1+2*kstride] = gout21;
    eri_ij[1+1*jstride+2*kstride] = gout22;
    //eri_ji[1*jstride+1+2*kstride] = gout22;
    eri_ij[2+1*jstride+2*kstride] = gout23;
    //eri_ji[2*jstride+1+2*kstride] = gout23;
    eri_ij[2*jstride+2*kstride] = gout24;
    //eri_ji[2+2*kstride] = gout24;
    eri_ij[1+2*jstride+2*kstride] = gout25;
    //eri_ji[1*jstride+2+2*kstride] = gout25;
    eri_ij[2+2*jstride+2*kstride] = gout26;
    //eri_ji[2*jstride+2+2*kstride] = gout26;
    eri_ij[3*kstride] = gout27;
    //eri_ji[3*kstride] = gout27;
    eri_ij[1+3*kstride] = gout28;
    //eri_ji[1*jstride+3*kstride] = gout28;
    eri_ij[2+3*kstride] = gout29;
    //eri_ji[2*jstride+3*kstride] = gout29;
    eri_ij[1*jstride+3*kstride] = gout30;
    //eri_ji[1+3*kstride] = gout30;
    eri_ij[1+1*jstride+3*kstride] = gout31;
    //eri_ji[1*jstride+1+3*kstride] = gout31;
    eri_ij[2+1*jstride+3*kstride] = gout32;
    //eri_ji[2*jstride+1+3*kstride] = gout32;
    eri_ij[2*jstride+3*kstride] = gout33;
    //eri_ji[2+3*kstride] = gout33;
    eri_ij[1+2*jstride+3*kstride] = gout34;
    //eri_ji[1*jstride+2+3*kstride] = gout34;
    eri_ij[2+2*jstride+3*kstride] = gout35;
    //eri_ji[2*jstride+2+3*kstride] = gout35;
    eri_ij[4*kstride] = gout36;
    //eri_ji[4*kstride] = gout36;
    eri_ij[1+4*kstride] = gout37;
    //eri_ji[1*jstride+4*kstride] = gout37;
    eri_ij[2+4*kstride] = gout38;
    //eri_ji[2*jstride+4*kstride] = gout38;
    eri_ij[1*jstride+4*kstride] = gout39;
    //eri_ji[1+4*kstride] = gout39;
    eri_ij[1+1*jstride+4*kstride] = gout40;
    //eri_ji[1*jstride+1+4*kstride] = gout40;
    eri_ij[2+1*jstride+4*kstride] = gout41;
    //eri_ji[2*jstride+1+4*kstride] = gout41;
    eri_ij[2*jstride+4*kstride] = gout42;
    //eri_ji[2+4*kstride] = gout42;
    eri_ij[1+2*jstride+4*kstride] = gout43;
    //eri_ji[1*jstride+2+4*kstride] = gout43;
    eri_ij[2+2*jstride+4*kstride] = gout44;
    //eri_ji[2*jstride+2+4*kstride] = gout44;
    eri_ij[5*kstride] = gout45;
    //eri_ji[5*kstride] = gout45;
    eri_ij[1+5*kstride] = gout46;
    //eri_ji[1*jstride+5*kstride] = gout46;
    eri_ij[2+5*kstride] = gout47;
    //eri_ji[2*jstride+5*kstride] = gout47;
    eri_ij[1*jstride+5*kstride] = gout48;
    //eri_ji[1+5*kstride] = gout48;
    eri_ij[1+1*jstride+5*kstride] = gout49;
    //eri_ji[1*jstride+1+5*kstride] = gout49;
    eri_ij[2+1*jstride+5*kstride] = gout50;
    //eri_ji[2*jstride+1+5*kstride] = gout50;
    eri_ij[2*jstride+5*kstride] = gout51;
    //eri_ji[2+5*kstride] = gout51;
    eri_ij[1+2*jstride+5*kstride] = gout52;
    //eri_ji[1*jstride+2+5*kstride] = gout52;
    eri_ij[2+2*jstride+5*kstride] = gout53;
    //eri_ji[2*jstride+2+5*kstride] = gout53;
    eri_ij[1*lstride] = gout54;
    //eri_ji[1*lstride] = gout54;
    eri_ij[1+1*lstride] = gout55;
    //eri_ji[1*jstride+1*lstride] = gout55;
    eri_ij[2+1*lstride] = gout56;
    //eri_ji[2*jstride+1*lstride] = gout56;
    eri_ij[1*jstride+1*lstride] = gout57;
    //eri_ji[1+1*lstride] = gout57;
    eri_ij[1+1*jstride+1*lstride] = gout58;
    //eri_ji[1*jstride+1+1*lstride] = gout58;
    eri_ij[2+1*jstride+1*lstride] = gout59;
    //eri_ji[2*jstride+1+1*lstride] = gout59;
    eri_ij[2*jstride+1*lstride] = gout60;
    //eri_ji[2+1*lstride] = gout60;
    eri_ij[1+2*jstride+1*lstride] = gout61;
    //eri_ji[1*jstride+2+1*lstride] = gout61;
    eri_ij[2+2*jstride+1*lstride] = gout62;
    //eri_ji[2*jstride+2+1*lstride] = gout62;
    eri_ij[1*kstride+1*lstride] = gout63;
    //eri_ji[1*kstride+1*lstride] = gout63;
    eri_ij[1+1*kstride+1*lstride] = gout64;
    //eri_ji[1*jstride+1*kstride+1*lstride] = gout64;
    eri_ij[2+1*kstride+1*lstride] = gout65;
    //eri_ji[2*jstride+1*kstride+1*lstride] = gout65;
    eri_ij[1*jstride+1*kstride+1*lstride] = gout66;
    //eri_ji[1+1*kstride+1*lstride] = gout66;
    eri_ij[1+1*jstride+1*kstride+1*lstride] = gout67;
    //eri_ji[1*jstride+1+1*kstride+1*lstride] = gout67;
    eri_ij[2+1*jstride+1*kstride+1*lstride] = gout68;
    //eri_ji[2*jstride+1+1*kstride+1*lstride] = gout68;
    eri_ij[2*jstride+1*kstride+1*lstride] = gout69;
    //eri_ji[2+1*kstride+1*lstride] = gout69;
    eri_ij[1+2*jstride+1*kstride+1*lstride] = gout70;
    //eri_ji[1*jstride+2+1*kstride+1*lstride] = gout70;
    eri_ij[2+2*jstride+1*kstride+1*lstride] = gout71;
    //eri_ji[2*jstride+2+1*kstride+1*lstride] = gout71;
    eri_ij[2*kstride+1*lstride] = gout72;
    //eri_ji[2*kstride+1*lstride] = gout72;
    eri_ij[1+2*kstride+1*lstride] = gout73;
    //eri_ji[1*jstride+2*kstride+1*lstride] = gout73;
    eri_ij[2+2*kstride+1*lstride] = gout74;
    //eri_ji[2*jstride+2*kstride+1*lstride] = gout74;
    eri_ij[1*jstride+2*kstride+1*lstride] = gout75;
    //eri_ji[1+2*kstride+1*lstride] = gout75;
    eri_ij[1+1*jstride+2*kstride+1*lstride] = gout76;
    //eri_ji[1*jstride+1+2*kstride+1*lstride] = gout76;
    eri_ij[2+1*jstride+2*kstride+1*lstride] = gout77;
    //eri_ji[2*jstride+1+2*kstride+1*lstride] = gout77;
    eri_ij[2*jstride+2*kstride+1*lstride] = gout78;
    //eri_ji[2+2*kstride+1*lstride] = gout78;
    eri_ij[1+2*jstride+2*kstride+1*lstride] = gout79;
    //eri_ji[1*jstride+2+2*kstride+1*lstride] = gout79;
    eri_ij[2+2*jstride+2*kstride+1*lstride] = gout80;
    //eri_ji[2*jstride+2+2*kstride+1*lstride] = gout80;
    eri_ij[3*kstride+1*lstride] = gout81;
    //eri_ji[3*kstride+1*lstride] = gout81;
    eri_ij[1+3*kstride+1*lstride] = gout82;
    //eri_ji[1*jstride+3*kstride+1*lstride] = gout82;
    eri_ij[2+3*kstride+1*lstride] = gout83;
    //eri_ji[2*jstride+3*kstride+1*lstride] = gout83;
    eri_ij[1*jstride+3*kstride+1*lstride] = gout84;
    //eri_ji[1+3*kstride+1*lstride] = gout84;
    eri_ij[1+1*jstride+3*kstride+1*lstride] = gout85;
    //eri_ji[1*jstride+1+3*kstride+1*lstride] = gout85;
    eri_ij[2+1*jstride+3*kstride+1*lstride] = gout86;
    //eri_ji[2*jstride+1+3*kstride+1*lstride] = gout86;
    eri_ij[2*jstride+3*kstride+1*lstride] = gout87;
    //eri_ji[2+3*kstride+1*lstride] = gout87;
    eri_ij[1+2*jstride+3*kstride+1*lstride] = gout88;
    //eri_ji[1*jstride+2+3*kstride+1*lstride] = gout88;
    eri_ij[2+2*jstride+3*kstride+1*lstride] = gout89;
    //eri_ji[2*jstride+2+3*kstride+1*lstride] = gout89;
    eri_ij[4*kstride+1*lstride] = gout90;
    //eri_ji[4*kstride+1*lstride] = gout90;
    eri_ij[1+4*kstride+1*lstride] = gout91;
    //eri_ji[1*jstride+4*kstride+1*lstride] = gout91;
    eri_ij[2+4*kstride+1*lstride] = gout92;
    //eri_ji[2*jstride+4*kstride+1*lstride] = gout92;
    eri_ij[1*jstride+4*kstride+1*lstride] = gout93;
    //eri_ji[1+4*kstride+1*lstride] = gout93;
    eri_ij[1+1*jstride+4*kstride+1*lstride] = gout94;
    //eri_ji[1*jstride+1+4*kstride+1*lstride] = gout94;
    eri_ij[2+1*jstride+4*kstride+1*lstride] = gout95;
    //eri_ji[2*jstride+1+4*kstride+1*lstride] = gout95;
    eri_ij[2*jstride+4*kstride+1*lstride] = gout96;
    //eri_ji[2+4*kstride+1*lstride] = gout96;
    eri_ij[1+2*jstride+4*kstride+1*lstride] = gout97;
    //eri_ji[1*jstride+2+4*kstride+1*lstride] = gout97;
    eri_ij[2+2*jstride+4*kstride+1*lstride] = gout98;
    //eri_ji[2*jstride+2+4*kstride+1*lstride] = gout98;
    eri_ij[5*kstride+1*lstride] = gout99;
    //eri_ji[5*kstride+1*lstride] = gout99;
    eri_ij[1+5*kstride+1*lstride] = gout100;
    //eri_ji[1*jstride+5*kstride+1*lstride] = gout100;
    eri_ij[2+5*kstride+1*lstride] = gout101;
    //eri_ji[2*jstride+5*kstride+1*lstride] = gout101;
    eri_ij[1*jstride+5*kstride+1*lstride] = gout102;
    //eri_ji[1+5*kstride+1*lstride] = gout102;
    eri_ij[1+1*jstride+5*kstride+1*lstride] = gout103;
    //eri_ji[1*jstride+1+5*kstride+1*lstride] = gout103;
    eri_ij[2+1*jstride+5*kstride+1*lstride] = gout104;
    //eri_ji[2*jstride+1+5*kstride+1*lstride] = gout104;
    eri_ij[2*jstride+5*kstride+1*lstride] = gout105;
    //eri_ji[2+5*kstride+1*lstride] = gout105;
    eri_ij[1+2*jstride+5*kstride+1*lstride] = gout106;
    //eri_ji[1*jstride+2+5*kstride+1*lstride] = gout106;
    eri_ij[2+2*jstride+5*kstride+1*lstride] = gout107;
    //eri_ji[2*jstride+2+5*kstride+1*lstride] = gout107;
    eri_ij[2*lstride] = gout108;
    //eri_ji[2*lstride] = gout108;
    eri_ij[1+2*lstride] = gout109;
    //eri_ji[1*jstride+2*lstride] = gout109;
    eri_ij[2+2*lstride] = gout110;
    //eri_ji[2*jstride+2*lstride] = gout110;
    eri_ij[1*jstride+2*lstride] = gout111;
    //eri_ji[1+2*lstride] = gout111;
    eri_ij[1+1*jstride+2*lstride] = gout112;
    //eri_ji[1*jstride+1+2*lstride] = gout112;
    eri_ij[2+1*jstride+2*lstride] = gout113;
    //eri_ji[2*jstride+1+2*lstride] = gout113;
    eri_ij[2*jstride+2*lstride] = gout114;
    //eri_ji[2+2*lstride] = gout114;
    eri_ij[1+2*jstride+2*lstride] = gout115;
    //eri_ji[1*jstride+2+2*lstride] = gout115;
    eri_ij[2+2*jstride+2*lstride] = gout116;
    //eri_ji[2*jstride+2+2*lstride] = gout116;
    eri_ij[1*kstride+2*lstride] = gout117;
    //eri_ji[1*kstride+2*lstride] = gout117;
    eri_ij[1+1*kstride+2*lstride] = gout118;
    //eri_ji[1*jstride+1*kstride+2*lstride] = gout118;
    eri_ij[2+1*kstride+2*lstride] = gout119;
    //eri_ji[2*jstride+1*kstride+2*lstride] = gout119;
    eri_ij[1*jstride+1*kstride+2*lstride] = gout120;
    //eri_ji[1+1*kstride+2*lstride] = gout120;
    eri_ij[1+1*jstride+1*kstride+2*lstride] = gout121;
    //eri_ji[1*jstride+1+1*kstride+2*lstride] = gout121;
    eri_ij[2+1*jstride+1*kstride+2*lstride] = gout122;
    //eri_ji[2*jstride+1+1*kstride+2*lstride] = gout122;
    eri_ij[2*jstride+1*kstride+2*lstride] = gout123;
    //eri_ji[2+1*kstride+2*lstride] = gout123;
    eri_ij[1+2*jstride+1*kstride+2*lstride] = gout124;
    //eri_ji[1*jstride+2+1*kstride+2*lstride] = gout124;
    eri_ij[2+2*jstride+1*kstride+2*lstride] = gout125;
    //eri_ji[2*jstride+2+1*kstride+2*lstride] = gout125;
    eri_ij[2*kstride+2*lstride] = gout126;
    //eri_ji[2*kstride+2*lstride] = gout126;
    eri_ij[1+2*kstride+2*lstride] = gout127;
    //eri_ji[1*jstride+2*kstride+2*lstride] = gout127;
    eri_ij[2+2*kstride+2*lstride] = gout128;
    //eri_ji[2*jstride+2*kstride+2*lstride] = gout128;
    eri_ij[1*jstride+2*kstride+2*lstride] = gout129;
    //eri_ji[1+2*kstride+2*lstride] = gout129;
    eri_ij[1+1*jstride+2*kstride+2*lstride] = gout130;
    //eri_ji[1*jstride+1+2*kstride+2*lstride] = gout130;
    eri_ij[2+1*jstride+2*kstride+2*lstride] = gout131;
    //eri_ji[2*jstride+1+2*kstride+2*lstride] = gout131;
    eri_ij[2*jstride+2*kstride+2*lstride] = gout132;
    //eri_ji[2+2*kstride+2*lstride] = gout132;
    eri_ij[1+2*jstride+2*kstride+2*lstride] = gout133;
    //eri_ji[1*jstride+2+2*kstride+2*lstride] = gout133;
    eri_ij[2+2*jstride+2*kstride+2*lstride] = gout134;
    //eri_ji[2*jstride+2+2*kstride+2*lstride] = gout134;
    eri_ij[3*kstride+2*lstride] = gout135;
    //eri_ji[3*kstride+2*lstride] = gout135;
    eri_ij[1+3*kstride+2*lstride] = gout136;
    //eri_ji[1*jstride+3*kstride+2*lstride] = gout136;
    eri_ij[2+3*kstride+2*lstride] = gout137;
    //eri_ji[2*jstride+3*kstride+2*lstride] = gout137;
    eri_ij[1*jstride+3*kstride+2*lstride] = gout138;
    //eri_ji[1+3*kstride+2*lstride] = gout138;
    eri_ij[1+1*jstride+3*kstride+2*lstride] = gout139;
    //eri_ji[1*jstride+1+3*kstride+2*lstride] = gout139;
    eri_ij[2+1*jstride+3*kstride+2*lstride] = gout140;
    //eri_ji[2*jstride+1+3*kstride+2*lstride] = gout140;
    eri_ij[2*jstride+3*kstride+2*lstride] = gout141;
    //eri_ji[2+3*kstride+2*lstride] = gout141;
    eri_ij[1+2*jstride+3*kstride+2*lstride] = gout142;
    //eri_ji[1*jstride+2+3*kstride+2*lstride] = gout142;
    eri_ij[2+2*jstride+3*kstride+2*lstride] = gout143;
    //eri_ji[2*jstride+2+3*kstride+2*lstride] = gout143;
    eri_ij[4*kstride+2*lstride] = gout144;
    //eri_ji[4*kstride+2*lstride] = gout144;
    eri_ij[1+4*kstride+2*lstride] = gout145;
    //eri_ji[1*jstride+4*kstride+2*lstride] = gout145;
    eri_ij[2+4*kstride+2*lstride] = gout146;
    //eri_ji[2*jstride+4*kstride+2*lstride] = gout146;
    eri_ij[1*jstride+4*kstride+2*lstride] = gout147;
    //eri_ji[1+4*kstride+2*lstride] = gout147;
    eri_ij[1+1*jstride+4*kstride+2*lstride] = gout148;
    //eri_ji[1*jstride+1+4*kstride+2*lstride] = gout148;
    eri_ij[2+1*jstride+4*kstride+2*lstride] = gout149;
    //eri_ji[2*jstride+1+4*kstride+2*lstride] = gout149;
    eri_ij[2*jstride+4*kstride+2*lstride] = gout150;
    //eri_ji[2+4*kstride+2*lstride] = gout150;
    eri_ij[1+2*jstride+4*kstride+2*lstride] = gout151;
    //eri_ji[1*jstride+2+4*kstride+2*lstride] = gout151;
    eri_ij[2+2*jstride+4*kstride+2*lstride] = gout152;
    //eri_ji[2*jstride+2+4*kstride+2*lstride] = gout152;
    eri_ij[5*kstride+2*lstride] = gout153;
    //eri_ji[5*kstride+2*lstride] = gout153;
    eri_ij[1+5*kstride+2*lstride] = gout154;
    //eri_ji[1*jstride+5*kstride+2*lstride] = gout154;
    eri_ij[2+5*kstride+2*lstride] = gout155;
    //eri_ji[2*jstride+5*kstride+2*lstride] = gout155;
    eri_ij[1*jstride+5*kstride+2*lstride] = gout156;
    //eri_ji[1+5*kstride+2*lstride] = gout156;
    eri_ij[1+1*jstride+5*kstride+2*lstride] = gout157;
    //eri_ji[1*jstride+1+5*kstride+2*lstride] = gout157;
    eri_ij[2+1*jstride+5*kstride+2*lstride] = gout158;
    //eri_ji[2*jstride+1+5*kstride+2*lstride] = gout158;
    eri_ij[2*jstride+5*kstride+2*lstride] = gout159;
    //eri_ji[2+5*kstride+2*lstride] = gout159;
    eri_ij[1+2*jstride+5*kstride+2*lstride] = gout160;
    //eri_ji[1*jstride+2+5*kstride+2*lstride] = gout160;
    eri_ij[2+2*jstride+5*kstride+2*lstride] = gout161;
    //eri_ji[2*jstride+2+5*kstride+2*lstride] = gout161;
}

__global__
static void GINTfill_int2e_kernel1130(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double gout36 = 0;
    double gout37 = 0;
    double gout38 = 0;
    double gout39 = 0;
    double gout40 = 0;
    double gout41 = 0;
    double gout42 = 0;
    double gout43 = 0;
    double gout44 = 0;
    double gout45 = 0;
    double gout46 = 0;
    double gout47 = 0;
    double gout48 = 0;
    double gout49 = 0;
    double gout50 = 0;
    double gout51 = 0;
    double gout52 = 0;
    double gout53 = 0;
    double gout54 = 0;
    double gout55 = 0;
    double gout56 = 0;
    double gout57 = 0;
    double gout58 = 0;
    double gout59 = 0;
    double gout60 = 0;
    double gout61 = 0;
    double gout62 = 0;
    double gout63 = 0;
    double gout64 = 0;
    double gout65 = 0;
    double gout66 = 0;
    double gout67 = 0;
    double gout68 = 0;
    double gout69 = 0;
    double gout70 = 0;
    double gout71 = 0;
    double gout72 = 0;
    double gout73 = 0;
    double gout74 = 0;
    double gout75 = 0;
    double gout76 = 0;
    double gout77 = 0;
    double gout78 = 0;
    double gout79 = 0;
    double gout80 = 0;
    double gout81 = 0;
    double gout82 = 0;
    double gout83 = 0;
    double gout84 = 0;
    double gout85 = 0;
    double gout86 = 0;
    double gout87 = 0;
    double gout88 = 0;
    double gout89 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xixj = xi - bas_x[jsh];
    double yiyj = yi - bas_y[jsh];
    double zizj = zi - bas_z[jsh];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double b10 = b00 + tmp4 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double b01 = b00 + tmp4 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c00x + xixj;
            double g_3 = c00x * (c00x + xixj) + b10;
            double g_4 = c0px;
            double g_5 = c0px * c00x + b00;
            double g_6 = c0px * (c00x + xixj) + b00;
            double g_7 = b00 * c00x + b10 * c0px + c00x * g_5 + xixj * g_5;
            double g_8 = c0px * c0px + b01;
            double g_9 = b00 * c0px + b01 * c00x + c0px * g_5;
            double g_10 = b00 * c0px + b01 * c00x + c0px * g_5 + xixj * g_8;
            double g_11 = 2 * b00 * g_5 + b10 * g_8 + c00x * g_9 + xixj * g_9;
            double g_12 = c0px * (2 * b01 + g_8);
            double g_13 = 2 * b01 * g_5 + b00 * g_8 + c0px * g_9;
            double g_14 = 2 * b01 * g_5 + b00 * g_8 + c0px * g_9 + xixj * g_12;
            double g_15 = 3 * b00 * g_9 + b10 * g_12 + c00x * g_13 + xixj * g_13;
            double g_16 = 1;
            double g_17 = c00y;
            double g_18 = c00y + yiyj;
            double g_19 = c00y * (c00y + yiyj) + b10;
            double g_20 = c0py;
            double g_21 = c0py * c00y + b00;
            double g_22 = c0py * (c00y + yiyj) + b00;
            double g_23 = b00 * c00y + b10 * c0py + c00y * g_21 + yiyj * g_21;
            double g_24 = c0py * c0py + b01;
            double g_25 = b00 * c0py + b01 * c00y + c0py * g_21;
            double g_26 = b00 * c0py + b01 * c00y + c0py * g_21 + yiyj * g_24;
            double g_27 = 2 * b00 * g_21 + b10 * g_24 + c00y * g_25 + yiyj * g_25;
            double g_28 = c0py * (2 * b01 + g_24);
            double g_29 = 2 * b01 * g_21 + b00 * g_24 + c0py * g_25;
            double g_30 = 2 * b01 * g_21 + b00 * g_24 + c0py * g_25 + yiyj * g_28;
            double g_31 = 3 * b00 * g_25 + b10 * g_28 + c00y * g_29 + yiyj * g_29;
            double g_32 = weight0 * fac;
            double g_33 = c00z * g_32;
            double g_34 = g_32 * (c00z + zizj);
            double g_35 = b10 * g_32 + c00z * g_33 + zizj * g_33;
            double g_36 = c0pz * g_32;
            double g_37 = b00 * g_32 + c0pz * g_33;
            double g_38 = b00 * g_32 + c0pz * g_33 + zizj * g_36;
            double g_39 = b00 * g_33 + b10 * g_36 + c00z * g_37 + zizj * g_37;
            double g_40 = b01 * g_32 + c0pz * g_36;
            double g_41 = b00 * g_36 + b01 * g_33 + c0pz * g_37;
            double g_42 = b00 * g_36 + b01 * g_33 + c0pz * g_37 + zizj * g_40;
            double g_43 = 2 * b00 * g_37 + b10 * g_40 + c00z * g_41 + zizj * g_41;
            double g_44 = 2 * b01 * g_36 + c0pz * g_40;
            double g_45 = 2 * b01 * g_37 + b00 * g_40 + c0pz * g_41;
            double g_46 = 2 * b01 * g_37 + b00 * g_40 + c0pz * g_41 + zizj * g_44;
            double g_47 = 3 * b00 * g_41 + b10 * g_44 + c00z * g_45 + zizj * g_45;
            gout0 += g_15 * g_16 * g_32;
            gout1 += g_14 * g_17 * g_32;
            gout2 += g_14 * g_16 * g_33;
            gout3 += g_13 * g_18 * g_32;
            gout4 += g_12 * g_19 * g_32;
            gout5 += g_12 * g_18 * g_33;
            gout6 += g_13 * g_16 * g_34;
            gout7 += g_12 * g_17 * g_34;
            gout8 += g_12 * g_16 * g_35;
            gout9 += g_11 * g_20 * g_32;
            gout10 += g_10 * g_21 * g_32;
            gout11 += g_10 * g_20 * g_33;
            gout12 += g_9 * g_22 * g_32;
            gout13 += g_8 * g_23 * g_32;
            gout14 += g_8 * g_22 * g_33;
            gout15 += g_9 * g_20 * g_34;
            gout16 += g_8 * g_21 * g_34;
            gout17 += g_8 * g_20 * g_35;
            gout18 += g_11 * g_16 * g_36;
            gout19 += g_10 * g_17 * g_36;
            gout20 += g_10 * g_16 * g_37;
            gout21 += g_9 * g_18 * g_36;
            gout22 += g_8 * g_19 * g_36;
            gout23 += g_8 * g_18 * g_37;
            gout24 += g_9 * g_16 * g_38;
            gout25 += g_8 * g_17 * g_38;
            gout26 += g_8 * g_16 * g_39;
            gout27 += g_7 * g_24 * g_32;
            gout28 += g_6 * g_25 * g_32;
            gout29 += g_6 * g_24 * g_33;
            gout30 += g_5 * g_26 * g_32;
            gout31 += g_4 * g_27 * g_32;
            gout32 += g_4 * g_26 * g_33;
            gout33 += g_5 * g_24 * g_34;
            gout34 += g_4 * g_25 * g_34;
            gout35 += g_4 * g_24 * g_35;
            gout36 += g_7 * g_20 * g_36;
            gout37 += g_6 * g_21 * g_36;
            gout38 += g_6 * g_20 * g_37;
            gout39 += g_5 * g_22 * g_36;
            gout40 += g_4 * g_23 * g_36;
            gout41 += g_4 * g_22 * g_37;
            gout42 += g_5 * g_20 * g_38;
            gout43 += g_4 * g_21 * g_38;
            gout44 += g_4 * g_20 * g_39;
            gout45 += g_7 * g_16 * g_40;
            gout46 += g_6 * g_17 * g_40;
            gout47 += g_6 * g_16 * g_41;
            gout48 += g_5 * g_18 * g_40;
            gout49 += g_4 * g_19 * g_40;
            gout50 += g_4 * g_18 * g_41;
            gout51 += g_5 * g_16 * g_42;
            gout52 += g_4 * g_17 * g_42;
            gout53 += g_4 * g_16 * g_43;
            gout54 += g_3 * g_28 * g_32;
            gout55 += g_2 * g_29 * g_32;
            gout56 += g_2 * g_28 * g_33;
            gout57 += g_1 * g_30 * g_32;
            gout58 += g_0 * g_31 * g_32;
            gout59 += g_0 * g_30 * g_33;
            gout60 += g_1 * g_28 * g_34;
            gout61 += g_0 * g_29 * g_34;
            gout62 += g_0 * g_28 * g_35;
            gout63 += g_3 * g_24 * g_36;
            gout64 += g_2 * g_25 * g_36;
            gout65 += g_2 * g_24 * g_37;
            gout66 += g_1 * g_26 * g_36;
            gout67 += g_0 * g_27 * g_36;
            gout68 += g_0 * g_26 * g_37;
            gout69 += g_1 * g_24 * g_38;
            gout70 += g_0 * g_25 * g_38;
            gout71 += g_0 * g_24 * g_39;
            gout72 += g_3 * g_20 * g_40;
            gout73 += g_2 * g_21 * g_40;
            gout74 += g_2 * g_20 * g_41;
            gout75 += g_1 * g_22 * g_40;
            gout76 += g_0 * g_23 * g_40;
            gout77 += g_0 * g_22 * g_41;
            gout78 += g_1 * g_20 * g_42;
            gout79 += g_0 * g_21 * g_42;
            gout80 += g_0 * g_20 * g_43;
            gout81 += g_3 * g_16 * g_44;
            gout82 += g_2 * g_17 * g_44;
            gout83 += g_2 * g_16 * g_45;
            gout84 += g_1 * g_18 * g_44;
            gout85 += g_0 * g_19 * g_44;
            gout86 += g_0 * g_18 * g_45;
            gout87 += g_1 * g_16 * g_46;
            gout88 += g_0 * g_17 * g_46;
            gout89 += g_0 * g_16 * g_47;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[1*jstride] = gout3;
    //eri_ji[1] = gout3;
    eri_ij[1+1*jstride] = gout4;
    //eri_ji[1*jstride+1] = gout4;
    eri_ij[2+1*jstride] = gout5;
    //eri_ji[2*jstride+1] = gout5;
    eri_ij[2*jstride] = gout6;
    //eri_ji[2] = gout6;
    eri_ij[1+2*jstride] = gout7;
    //eri_ji[1*jstride+2] = gout7;
    eri_ij[2+2*jstride] = gout8;
    //eri_ji[2*jstride+2] = gout8;
    eri_ij[1*kstride] = gout9;
    //eri_ji[1*kstride] = gout9;
    eri_ij[1+1*kstride] = gout10;
    //eri_ji[1*jstride+1*kstride] = gout10;
    eri_ij[2+1*kstride] = gout11;
    //eri_ji[2*jstride+1*kstride] = gout11;
    eri_ij[1*jstride+1*kstride] = gout12;
    //eri_ji[1+1*kstride] = gout12;
    eri_ij[1+1*jstride+1*kstride] = gout13;
    //eri_ji[1*jstride+1+1*kstride] = gout13;
    eri_ij[2+1*jstride+1*kstride] = gout14;
    //eri_ji[2*jstride+1+1*kstride] = gout14;
    eri_ij[2*jstride+1*kstride] = gout15;
    //eri_ji[2+1*kstride] = gout15;
    eri_ij[1+2*jstride+1*kstride] = gout16;
    //eri_ji[1*jstride+2+1*kstride] = gout16;
    eri_ij[2+2*jstride+1*kstride] = gout17;
    //eri_ji[2*jstride+2+1*kstride] = gout17;
    eri_ij[2*kstride] = gout18;
    //eri_ji[2*kstride] = gout18;
    eri_ij[1+2*kstride] = gout19;
    //eri_ji[1*jstride+2*kstride] = gout19;
    eri_ij[2+2*kstride] = gout20;
    //eri_ji[2*jstride+2*kstride] = gout20;
    eri_ij[1*jstride+2*kstride] = gout21;
    //eri_ji[1+2*kstride] = gout21;
    eri_ij[1+1*jstride+2*kstride] = gout22;
    //eri_ji[1*jstride+1+2*kstride] = gout22;
    eri_ij[2+1*jstride+2*kstride] = gout23;
    //eri_ji[2*jstride+1+2*kstride] = gout23;
    eri_ij[2*jstride+2*kstride] = gout24;
    //eri_ji[2+2*kstride] = gout24;
    eri_ij[1+2*jstride+2*kstride] = gout25;
    //eri_ji[1*jstride+2+2*kstride] = gout25;
    eri_ij[2+2*jstride+2*kstride] = gout26;
    //eri_ji[2*jstride+2+2*kstride] = gout26;
    eri_ij[3*kstride] = gout27;
    //eri_ji[3*kstride] = gout27;
    eri_ij[1+3*kstride] = gout28;
    //eri_ji[1*jstride+3*kstride] = gout28;
    eri_ij[2+3*kstride] = gout29;
    //eri_ji[2*jstride+3*kstride] = gout29;
    eri_ij[1*jstride+3*kstride] = gout30;
    //eri_ji[1+3*kstride] = gout30;
    eri_ij[1+1*jstride+3*kstride] = gout31;
    //eri_ji[1*jstride+1+3*kstride] = gout31;
    eri_ij[2+1*jstride+3*kstride] = gout32;
    //eri_ji[2*jstride+1+3*kstride] = gout32;
    eri_ij[2*jstride+3*kstride] = gout33;
    //eri_ji[2+3*kstride] = gout33;
    eri_ij[1+2*jstride+3*kstride] = gout34;
    //eri_ji[1*jstride+2+3*kstride] = gout34;
    eri_ij[2+2*jstride+3*kstride] = gout35;
    //eri_ji[2*jstride+2+3*kstride] = gout35;
    eri_ij[4*kstride] = gout36;
    //eri_ji[4*kstride] = gout36;
    eri_ij[1+4*kstride] = gout37;
    //eri_ji[1*jstride+4*kstride] = gout37;
    eri_ij[2+4*kstride] = gout38;
    //eri_ji[2*jstride+4*kstride] = gout38;
    eri_ij[1*jstride+4*kstride] = gout39;
    //eri_ji[1+4*kstride] = gout39;
    eri_ij[1+1*jstride+4*kstride] = gout40;
    //eri_ji[1*jstride+1+4*kstride] = gout40;
    eri_ij[2+1*jstride+4*kstride] = gout41;
    //eri_ji[2*jstride+1+4*kstride] = gout41;
    eri_ij[2*jstride+4*kstride] = gout42;
    //eri_ji[2+4*kstride] = gout42;
    eri_ij[1+2*jstride+4*kstride] = gout43;
    //eri_ji[1*jstride+2+4*kstride] = gout43;
    eri_ij[2+2*jstride+4*kstride] = gout44;
    //eri_ji[2*jstride+2+4*kstride] = gout44;
    eri_ij[5*kstride] = gout45;
    //eri_ji[5*kstride] = gout45;
    eri_ij[1+5*kstride] = gout46;
    //eri_ji[1*jstride+5*kstride] = gout46;
    eri_ij[2+5*kstride] = gout47;
    //eri_ji[2*jstride+5*kstride] = gout47;
    eri_ij[1*jstride+5*kstride] = gout48;
    //eri_ji[1+5*kstride] = gout48;
    eri_ij[1+1*jstride+5*kstride] = gout49;
    //eri_ji[1*jstride+1+5*kstride] = gout49;
    eri_ij[2+1*jstride+5*kstride] = gout50;
    //eri_ji[2*jstride+1+5*kstride] = gout50;
    eri_ij[2*jstride+5*kstride] = gout51;
    //eri_ji[2+5*kstride] = gout51;
    eri_ij[1+2*jstride+5*kstride] = gout52;
    //eri_ji[1*jstride+2+5*kstride] = gout52;
    eri_ij[2+2*jstride+5*kstride] = gout53;
    //eri_ji[2*jstride+2+5*kstride] = gout53;
    eri_ij[6*kstride] = gout54;
    //eri_ji[6*kstride] = gout54;
    eri_ij[1+6*kstride] = gout55;
    //eri_ji[1*jstride+6*kstride] = gout55;
    eri_ij[2+6*kstride] = gout56;
    //eri_ji[2*jstride+6*kstride] = gout56;
    eri_ij[1*jstride+6*kstride] = gout57;
    //eri_ji[1+6*kstride] = gout57;
    eri_ij[1+1*jstride+6*kstride] = gout58;
    //eri_ji[1*jstride+1+6*kstride] = gout58;
    eri_ij[2+1*jstride+6*kstride] = gout59;
    //eri_ji[2*jstride+1+6*kstride] = gout59;
    eri_ij[2*jstride+6*kstride] = gout60;
    //eri_ji[2+6*kstride] = gout60;
    eri_ij[1+2*jstride+6*kstride] = gout61;
    //eri_ji[1*jstride+2+6*kstride] = gout61;
    eri_ij[2+2*jstride+6*kstride] = gout62;
    //eri_ji[2*jstride+2+6*kstride] = gout62;
    eri_ij[7*kstride] = gout63;
    //eri_ji[7*kstride] = gout63;
    eri_ij[1+7*kstride] = gout64;
    //eri_ji[1*jstride+7*kstride] = gout64;
    eri_ij[2+7*kstride] = gout65;
    //eri_ji[2*jstride+7*kstride] = gout65;
    eri_ij[1*jstride+7*kstride] = gout66;
    //eri_ji[1+7*kstride] = gout66;
    eri_ij[1+1*jstride+7*kstride] = gout67;
    //eri_ji[1*jstride+1+7*kstride] = gout67;
    eri_ij[2+1*jstride+7*kstride] = gout68;
    //eri_ji[2*jstride+1+7*kstride] = gout68;
    eri_ij[2*jstride+7*kstride] = gout69;
    //eri_ji[2+7*kstride] = gout69;
    eri_ij[1+2*jstride+7*kstride] = gout70;
    //eri_ji[1*jstride+2+7*kstride] = gout70;
    eri_ij[2+2*jstride+7*kstride] = gout71;
    //eri_ji[2*jstride+2+7*kstride] = gout71;
    eri_ij[8*kstride] = gout72;
    //eri_ji[8*kstride] = gout72;
    eri_ij[1+8*kstride] = gout73;
    //eri_ji[1*jstride+8*kstride] = gout73;
    eri_ij[2+8*kstride] = gout74;
    //eri_ji[2*jstride+8*kstride] = gout74;
    eri_ij[1*jstride+8*kstride] = gout75;
    //eri_ji[1+8*kstride] = gout75;
    eri_ij[1+1*jstride+8*kstride] = gout76;
    //eri_ji[1*jstride+1+8*kstride] = gout76;
    eri_ij[2+1*jstride+8*kstride] = gout77;
    //eri_ji[2*jstride+1+8*kstride] = gout77;
    eri_ij[2*jstride+8*kstride] = gout78;
    //eri_ji[2+8*kstride] = gout78;
    eri_ij[1+2*jstride+8*kstride] = gout79;
    //eri_ji[1*jstride+2+8*kstride] = gout79;
    eri_ij[2+2*jstride+8*kstride] = gout80;
    //eri_ji[2*jstride+2+8*kstride] = gout80;
    eri_ij[9*kstride] = gout81;
    //eri_ji[9*kstride] = gout81;
    eri_ij[1+9*kstride] = gout82;
    //eri_ji[1*jstride+9*kstride] = gout82;
    eri_ij[2+9*kstride] = gout83;
    //eri_ji[2*jstride+9*kstride] = gout83;
    eri_ij[1*jstride+9*kstride] = gout84;
    //eri_ji[1+9*kstride] = gout84;
    eri_ij[1+1*jstride+9*kstride] = gout85;
    //eri_ji[1*jstride+1+9*kstride] = gout85;
    eri_ij[2+1*jstride+9*kstride] = gout86;
    //eri_ji[2*jstride+1+9*kstride] = gout86;
    eri_ij[2*jstride+9*kstride] = gout87;
    //eri_ji[2+9*kstride] = gout87;
    eri_ij[1+2*jstride+9*kstride] = gout88;
    //eri_ji[1*jstride+2+9*kstride] = gout88;
    eri_ij[2+2*jstride+9*kstride] = gout89;
    //eri_ji[2*jstride+2+9*kstride] = gout89;
}

__global__
static void GINTfill_int2e_kernel2011(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double gout36 = 0;
    double gout37 = 0;
    double gout38 = 0;
    double gout39 = 0;
    double gout40 = 0;
    double gout41 = 0;
    double gout42 = 0;
    double gout43 = 0;
    double gout44 = 0;
    double gout45 = 0;
    double gout46 = 0;
    double gout47 = 0;
    double gout48 = 0;
    double gout49 = 0;
    double gout50 = 0;
    double gout51 = 0;
    double gout52 = 0;
    double gout53 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    double xkxl = xk - bas_x[lsh];
    double ykyl = yk - bas_y[lsh];
    double zkzl = zk - bas_z[lsh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double b10 = b00 + tmp4 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double b01 = b00 + tmp4 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c00x * c00x + b10;
            double g_3 = c0px;
            double g_4 = c0px * c00x + b00;
            double g_5 = b00 * c00x + b10 * c0px + c00x * g_4;
            double g_6 = c0px + xkxl;
            double g_7 = c00x * (c0px + xkxl) + b00;
            double g_8 = b00 * c00x + b10 * c0px + c00x * g_4 + xkxl * g_2;
            double g_9 = c0px * (c0px + xkxl) + b01;
            double g_10 = b00 * c0px + b01 * c00x + c0px * g_4 + xkxl * g_4;
            double g_11 = xkxl * g_5 + c00x * (c0px * g_4 + b01 * c00x + b00 * c0px) + b10 * (c0px * c0px + b01) + 2 * b00 * g_4;
            double g_12 = 1;
            double g_13 = c00y;
            double g_14 = c00y * c00y + b10;
            double g_15 = c0py;
            double g_16 = c0py * c00y + b00;
            double g_17 = b00 * c00y + b10 * c0py + c00y * g_16;
            double g_18 = c0py + ykyl;
            double g_19 = c00y * (c0py + ykyl) + b00;
            double g_20 = b00 * c00y + b10 * c0py + c00y * g_16 + ykyl * g_14;
            double g_21 = c0py * (c0py + ykyl) + b01;
            double g_22 = b00 * c0py + b01 * c00y + c0py * g_16 + ykyl * g_16;
            double g_23 = ykyl * g_17 + c00y * (c0py * g_16 + b01 * c00y + b00 * c0py) + b10 * (c0py * c0py + b01) + 2 * b00 * g_16;
            double g_24 = weight0 * fac;
            double g_25 = c00z * g_24;
            double g_26 = b10 * g_24 + c00z * g_25;
            double g_27 = c0pz * g_24;
            double g_28 = b00 * g_24 + c0pz * g_25;
            double g_29 = b00 * g_25 + b10 * g_27 + c00z * g_28;
            double g_30 = g_24 * (c0pz + zkzl);
            double g_31 = b00 * g_24 + c0pz * g_25 + zkzl * g_25;
            double g_32 = b00 * g_25 + b10 * g_27 + c00z * g_28 + zkzl * g_26;
            double g_33 = b01 * g_24 + c0pz * g_27 + zkzl * g_27;
            double g_34 = b00 * g_27 + b01 * g_25 + c0pz * g_28 + zkzl * g_28;
            double g_35 = zkzl * g_29 + c00z * (c0pz * g_28 + b01 * g_25 + b00 * g_27) + b10 * (c0pz * g_27 + b01 * g_24) + 2 * b00 * g_28;
            gout0 += g_11 * g_12 * g_24;
            gout1 += g_10 * g_13 * g_24;
            gout2 += g_10 * g_12 * g_25;
            gout3 += g_9 * g_14 * g_24;
            gout4 += g_9 * g_13 * g_25;
            gout5 += g_9 * g_12 * g_26;
            gout6 += g_8 * g_15 * g_24;
            gout7 += g_7 * g_16 * g_24;
            gout8 += g_7 * g_15 * g_25;
            gout9 += g_6 * g_17 * g_24;
            gout10 += g_6 * g_16 * g_25;
            gout11 += g_6 * g_15 * g_26;
            gout12 += g_8 * g_12 * g_27;
            gout13 += g_7 * g_13 * g_27;
            gout14 += g_7 * g_12 * g_28;
            gout15 += g_6 * g_14 * g_27;
            gout16 += g_6 * g_13 * g_28;
            gout17 += g_6 * g_12 * g_29;
            gout18 += g_5 * g_18 * g_24;
            gout19 += g_4 * g_19 * g_24;
            gout20 += g_4 * g_18 * g_25;
            gout21 += g_3 * g_20 * g_24;
            gout22 += g_3 * g_19 * g_25;
            gout23 += g_3 * g_18 * g_26;
            gout24 += g_2 * g_21 * g_24;
            gout25 += g_1 * g_22 * g_24;
            gout26 += g_1 * g_21 * g_25;
            gout27 += g_0 * g_23 * g_24;
            gout28 += g_0 * g_22 * g_25;
            gout29 += g_0 * g_21 * g_26;
            gout30 += g_2 * g_18 * g_27;
            gout31 += g_1 * g_19 * g_27;
            gout32 += g_1 * g_18 * g_28;
            gout33 += g_0 * g_20 * g_27;
            gout34 += g_0 * g_19 * g_28;
            gout35 += g_0 * g_18 * g_29;
            gout36 += g_5 * g_12 * g_30;
            gout37 += g_4 * g_13 * g_30;
            gout38 += g_4 * g_12 * g_31;
            gout39 += g_3 * g_14 * g_30;
            gout40 += g_3 * g_13 * g_31;
            gout41 += g_3 * g_12 * g_32;
            gout42 += g_2 * g_15 * g_30;
            gout43 += g_1 * g_16 * g_30;
            gout44 += g_1 * g_15 * g_31;
            gout45 += g_0 * g_17 * g_30;
            gout46 += g_0 * g_16 * g_31;
            gout47 += g_0 * g_15 * g_32;
            gout48 += g_2 * g_12 * g_33;
            gout49 += g_1 * g_13 * g_33;
            gout50 += g_1 * g_12 * g_34;
            gout51 += g_0 * g_14 * g_33;
            gout52 += g_0 * g_13 * g_34;
            gout53 += g_0 * g_12 * g_35;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[3] = gout3;
    //eri_ji[3*jstride] = gout3;
    eri_ij[4] = gout4;
    //eri_ji[4*jstride] = gout4;
    eri_ij[5] = gout5;
    //eri_ji[5*jstride] = gout5;
    eri_ij[1*kstride] = gout6;
    //eri_ji[1*kstride] = gout6;
    eri_ij[1+1*kstride] = gout7;
    //eri_ji[1*jstride+1*kstride] = gout7;
    eri_ij[2+1*kstride] = gout8;
    //eri_ji[2*jstride+1*kstride] = gout8;
    eri_ij[3+1*kstride] = gout9;
    //eri_ji[3*jstride+1*kstride] = gout9;
    eri_ij[4+1*kstride] = gout10;
    //eri_ji[4*jstride+1*kstride] = gout10;
    eri_ij[5+1*kstride] = gout11;
    //eri_ji[5*jstride+1*kstride] = gout11;
    eri_ij[2*kstride] = gout12;
    //eri_ji[2*kstride] = gout12;
    eri_ij[1+2*kstride] = gout13;
    //eri_ji[1*jstride+2*kstride] = gout13;
    eri_ij[2+2*kstride] = gout14;
    //eri_ji[2*jstride+2*kstride] = gout14;
    eri_ij[3+2*kstride] = gout15;
    //eri_ji[3*jstride+2*kstride] = gout15;
    eri_ij[4+2*kstride] = gout16;
    //eri_ji[4*jstride+2*kstride] = gout16;
    eri_ij[5+2*kstride] = gout17;
    //eri_ji[5*jstride+2*kstride] = gout17;
    eri_ij[1*lstride] = gout18;
    //eri_ji[1*lstride] = gout18;
    eri_ij[1+1*lstride] = gout19;
    //eri_ji[1*jstride+1*lstride] = gout19;
    eri_ij[2+1*lstride] = gout20;
    //eri_ji[2*jstride+1*lstride] = gout20;
    eri_ij[3+1*lstride] = gout21;
    //eri_ji[3*jstride+1*lstride] = gout21;
    eri_ij[4+1*lstride] = gout22;
    //eri_ji[4*jstride+1*lstride] = gout22;
    eri_ij[5+1*lstride] = gout23;
    //eri_ji[5*jstride+1*lstride] = gout23;
    eri_ij[1*kstride+1*lstride] = gout24;
    //eri_ji[1*kstride+1*lstride] = gout24;
    eri_ij[1+1*kstride+1*lstride] = gout25;
    //eri_ji[1*jstride+1*kstride+1*lstride] = gout25;
    eri_ij[2+1*kstride+1*lstride] = gout26;
    //eri_ji[2*jstride+1*kstride+1*lstride] = gout26;
    eri_ij[3+1*kstride+1*lstride] = gout27;
    //eri_ji[3*jstride+1*kstride+1*lstride] = gout27;
    eri_ij[4+1*kstride+1*lstride] = gout28;
    //eri_ji[4*jstride+1*kstride+1*lstride] = gout28;
    eri_ij[5+1*kstride+1*lstride] = gout29;
    //eri_ji[5*jstride+1*kstride+1*lstride] = gout29;
    eri_ij[2*kstride+1*lstride] = gout30;
    //eri_ji[2*kstride+1*lstride] = gout30;
    eri_ij[1+2*kstride+1*lstride] = gout31;
    //eri_ji[1*jstride+2*kstride+1*lstride] = gout31;
    eri_ij[2+2*kstride+1*lstride] = gout32;
    //eri_ji[2*jstride+2*kstride+1*lstride] = gout32;
    eri_ij[3+2*kstride+1*lstride] = gout33;
    //eri_ji[3*jstride+2*kstride+1*lstride] = gout33;
    eri_ij[4+2*kstride+1*lstride] = gout34;
    //eri_ji[4*jstride+2*kstride+1*lstride] = gout34;
    eri_ij[5+2*kstride+1*lstride] = gout35;
    //eri_ji[5*jstride+2*kstride+1*lstride] = gout35;
    eri_ij[2*lstride] = gout36;
    //eri_ji[2*lstride] = gout36;
    eri_ij[1+2*lstride] = gout37;
    //eri_ji[1*jstride+2*lstride] = gout37;
    eri_ij[2+2*lstride] = gout38;
    //eri_ji[2*jstride+2*lstride] = gout38;
    eri_ij[3+2*lstride] = gout39;
    //eri_ji[3*jstride+2*lstride] = gout39;
    eri_ij[4+2*lstride] = gout40;
    //eri_ji[4*jstride+2*lstride] = gout40;
    eri_ij[5+2*lstride] = gout41;
    //eri_ji[5*jstride+2*lstride] = gout41;
    eri_ij[1*kstride+2*lstride] = gout42;
    //eri_ji[1*kstride+2*lstride] = gout42;
    eri_ij[1+1*kstride+2*lstride] = gout43;
    //eri_ji[1*jstride+1*kstride+2*lstride] = gout43;
    eri_ij[2+1*kstride+2*lstride] = gout44;
    //eri_ji[2*jstride+1*kstride+2*lstride] = gout44;
    eri_ij[3+1*kstride+2*lstride] = gout45;
    //eri_ji[3*jstride+1*kstride+2*lstride] = gout45;
    eri_ij[4+1*kstride+2*lstride] = gout46;
    //eri_ji[4*jstride+1*kstride+2*lstride] = gout46;
    eri_ij[5+1*kstride+2*lstride] = gout47;
    //eri_ji[5*jstride+1*kstride+2*lstride] = gout47;
    eri_ij[2*kstride+2*lstride] = gout48;
    //eri_ji[2*kstride+2*lstride] = gout48;
    eri_ij[1+2*kstride+2*lstride] = gout49;
    //eri_ji[1*jstride+2*kstride+2*lstride] = gout49;
    eri_ij[2+2*kstride+2*lstride] = gout50;
    //eri_ji[2*jstride+2*kstride+2*lstride] = gout50;
    eri_ij[3+2*kstride+2*lstride] = gout51;
    //eri_ji[3*jstride+2*kstride+2*lstride] = gout51;
    eri_ij[4+2*kstride+2*lstride] = gout52;
    //eri_ji[4*jstride+2*kstride+2*lstride] = gout52;
    eri_ij[5+2*kstride+2*lstride] = gout53;
    //eri_ji[5*jstride+2*kstride+2*lstride] = gout53;
}

__global__
static void GINTfill_int2e_kernel2020(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double b10 = b00 + tmp4 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double b01 = b00 + tmp4 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c00x * c00x + b10;
            double g_3 = c0px;
            double g_4 = c0px * c00x + b00;
            double g_5 = b00 * c00x + b10 * c0px + c00x * g_4;
            double g_6 = c0px * c0px + b01;
            double g_7 = b00 * c0px + b01 * c00x + c0px * g_4;
            double g_8 = 2 * b00 * g_4 + b10 * g_6 + c00x * g_7;
            double g_9 = 1;
            double g_10 = c00y;
            double g_11 = c00y * c00y + b10;
            double g_12 = c0py;
            double g_13 = c0py * c00y + b00;
            double g_14 = b00 * c00y + b10 * c0py + c00y * g_13;
            double g_15 = c0py * c0py + b01;
            double g_16 = b00 * c0py + b01 * c00y + c0py * g_13;
            double g_17 = 2 * b00 * g_13 + b10 * g_15 + c00y * g_16;
            double g_18 = weight0 * fac;
            double g_19 = c00z * g_18;
            double g_20 = b10 * g_18 + c00z * g_19;
            double g_21 = c0pz * g_18;
            double g_22 = b00 * g_18 + c0pz * g_19;
            double g_23 = b00 * g_19 + b10 * g_21 + c00z * g_22;
            double g_24 = b01 * g_18 + c0pz * g_21;
            double g_25 = b00 * g_21 + b01 * g_19 + c0pz * g_22;
            double g_26 = 2 * b00 * g_22 + b10 * g_24 + c00z * g_25;
            gout0 += g_8 * g_9 * g_18;
            gout1 += g_7 * g_10 * g_18;
            gout2 += g_7 * g_9 * g_19;
            gout3 += g_6 * g_11 * g_18;
            gout4 += g_6 * g_10 * g_19;
            gout5 += g_6 * g_9 * g_20;
            gout6 += g_5 * g_12 * g_18;
            gout7 += g_4 * g_13 * g_18;
            gout8 += g_4 * g_12 * g_19;
            gout9 += g_3 * g_14 * g_18;
            gout10 += g_3 * g_13 * g_19;
            gout11 += g_3 * g_12 * g_20;
            gout12 += g_5 * g_9 * g_21;
            gout13 += g_4 * g_10 * g_21;
            gout14 += g_4 * g_9 * g_22;
            gout15 += g_3 * g_11 * g_21;
            gout16 += g_3 * g_10 * g_22;
            gout17 += g_3 * g_9 * g_23;
            gout18 += g_2 * g_15 * g_18;
            gout19 += g_1 * g_16 * g_18;
            gout20 += g_1 * g_15 * g_19;
            gout21 += g_0 * g_17 * g_18;
            gout22 += g_0 * g_16 * g_19;
            gout23 += g_0 * g_15 * g_20;
            gout24 += g_2 * g_12 * g_21;
            gout25 += g_1 * g_13 * g_21;
            gout26 += g_1 * g_12 * g_22;
            gout27 += g_0 * g_14 * g_21;
            gout28 += g_0 * g_13 * g_22;
            gout29 += g_0 * g_12 * g_23;
            gout30 += g_2 * g_9 * g_24;
            gout31 += g_1 * g_10 * g_24;
            gout32 += g_1 * g_9 * g_25;
            gout33 += g_0 * g_11 * g_24;
            gout34 += g_0 * g_10 * g_25;
            gout35 += g_0 * g_9 * g_26;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[3] = gout3;
    //eri_ji[3*jstride] = gout3;
    eri_ij[4] = gout4;
    //eri_ji[4*jstride] = gout4;
    eri_ij[5] = gout5;
    //eri_ji[5*jstride] = gout5;
    eri_ij[1*kstride] = gout6;
    //eri_ji[1*kstride] = gout6;
    eri_ij[1+1*kstride] = gout7;
    //eri_ji[1*jstride+1*kstride] = gout7;
    eri_ij[2+1*kstride] = gout8;
    //eri_ji[2*jstride+1*kstride] = gout8;
    eri_ij[3+1*kstride] = gout9;
    //eri_ji[3*jstride+1*kstride] = gout9;
    eri_ij[4+1*kstride] = gout10;
    //eri_ji[4*jstride+1*kstride] = gout10;
    eri_ij[5+1*kstride] = gout11;
    //eri_ji[5*jstride+1*kstride] = gout11;
    eri_ij[2*kstride] = gout12;
    //eri_ji[2*kstride] = gout12;
    eri_ij[1+2*kstride] = gout13;
    //eri_ji[1*jstride+2*kstride] = gout13;
    eri_ij[2+2*kstride] = gout14;
    //eri_ji[2*jstride+2*kstride] = gout14;
    eri_ij[3+2*kstride] = gout15;
    //eri_ji[3*jstride+2*kstride] = gout15;
    eri_ij[4+2*kstride] = gout16;
    //eri_ji[4*jstride+2*kstride] = gout16;
    eri_ij[5+2*kstride] = gout17;
    //eri_ji[5*jstride+2*kstride] = gout17;
    eri_ij[3*kstride] = gout18;
    //eri_ji[3*kstride] = gout18;
    eri_ij[1+3*kstride] = gout19;
    //eri_ji[1*jstride+3*kstride] = gout19;
    eri_ij[2+3*kstride] = gout20;
    //eri_ji[2*jstride+3*kstride] = gout20;
    eri_ij[3+3*kstride] = gout21;
    //eri_ji[3*jstride+3*kstride] = gout21;
    eri_ij[4+3*kstride] = gout22;
    //eri_ji[4*jstride+3*kstride] = gout22;
    eri_ij[5+3*kstride] = gout23;
    //eri_ji[5*jstride+3*kstride] = gout23;
    eri_ij[4*kstride] = gout24;
    //eri_ji[4*kstride] = gout24;
    eri_ij[1+4*kstride] = gout25;
    //eri_ji[1*jstride+4*kstride] = gout25;
    eri_ij[2+4*kstride] = gout26;
    //eri_ji[2*jstride+4*kstride] = gout26;
    eri_ij[3+4*kstride] = gout27;
    //eri_ji[3*jstride+4*kstride] = gout27;
    eri_ij[4+4*kstride] = gout28;
    //eri_ji[4*jstride+4*kstride] = gout28;
    eri_ij[5+4*kstride] = gout29;
    //eri_ji[5*jstride+4*kstride] = gout29;
    eri_ij[5*kstride] = gout30;
    //eri_ji[5*kstride] = gout30;
    eri_ij[1+5*kstride] = gout31;
    //eri_ji[1*jstride+5*kstride] = gout31;
    eri_ij[2+5*kstride] = gout32;
    //eri_ji[2*jstride+5*kstride] = gout32;
    eri_ij[3+5*kstride] = gout33;
    //eri_ji[3*jstride+5*kstride] = gout33;
    eri_ij[4+5*kstride] = gout34;
    //eri_ji[4*jstride+5*kstride] = gout34;
    eri_ij[5+5*kstride] = gout35;
    //eri_ji[5*jstride+5*kstride] = gout35;
}

__global__
static void GINTfill_int2e_kernel2021(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double gout36 = 0;
    double gout37 = 0;
    double gout38 = 0;
    double gout39 = 0;
    double gout40 = 0;
    double gout41 = 0;
    double gout42 = 0;
    double gout43 = 0;
    double gout44 = 0;
    double gout45 = 0;
    double gout46 = 0;
    double gout47 = 0;
    double gout48 = 0;
    double gout49 = 0;
    double gout50 = 0;
    double gout51 = 0;
    double gout52 = 0;
    double gout53 = 0;
    double gout54 = 0;
    double gout55 = 0;
    double gout56 = 0;
    double gout57 = 0;
    double gout58 = 0;
    double gout59 = 0;
    double gout60 = 0;
    double gout61 = 0;
    double gout62 = 0;
    double gout63 = 0;
    double gout64 = 0;
    double gout65 = 0;
    double gout66 = 0;
    double gout67 = 0;
    double gout68 = 0;
    double gout69 = 0;
    double gout70 = 0;
    double gout71 = 0;
    double gout72 = 0;
    double gout73 = 0;
    double gout74 = 0;
    double gout75 = 0;
    double gout76 = 0;
    double gout77 = 0;
    double gout78 = 0;
    double gout79 = 0;
    double gout80 = 0;
    double gout81 = 0;
    double gout82 = 0;
    double gout83 = 0;
    double gout84 = 0;
    double gout85 = 0;
    double gout86 = 0;
    double gout87 = 0;
    double gout88 = 0;
    double gout89 = 0;
    double gout90 = 0;
    double gout91 = 0;
    double gout92 = 0;
    double gout93 = 0;
    double gout94 = 0;
    double gout95 = 0;
    double gout96 = 0;
    double gout97 = 0;
    double gout98 = 0;
    double gout99 = 0;
    double gout100 = 0;
    double gout101 = 0;
    double gout102 = 0;
    double gout103 = 0;
    double gout104 = 0;
    double gout105 = 0;
    double gout106 = 0;
    double gout107 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    double xkxl = xk - bas_x[lsh];
    double ykyl = yk - bas_y[lsh];
    double zkzl = zk - bas_z[lsh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double b10 = b00 + tmp4 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double b01 = b00 + tmp4 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c00x * c00x + b10;
            double g_3 = c0px;
            double g_4 = c0px * c00x + b00;
            double g_5 = b00 * c00x + b10 * c0px + c00x * g_4;
            double g_6 = c0px * c0px + b01;
            double g_7 = b00 * c0px + b01 * c00x + c0px * g_4;
            double g_8 = 2 * b00 * g_4 + b10 * g_6 + c00x * g_7;
            double g_9 = c0px + xkxl;
            double g_10 = c00x * (c0px + xkxl) + b00;
            double g_11 = b00 * c00x + b10 * c0px + c00x * g_4 + xkxl * g_2;
            double g_12 = c0px * (c0px + xkxl) + b01;
            double g_13 = b00 * c0px + b01 * c00x + c0px * g_4 + xkxl * g_4;
            double g_14 = 2 * b00 * g_4 + b10 * g_6 + c00x * g_7 + xkxl * g_5;
            double g_15 = c0px * (2 * b01 + g_6) + xkxl * g_6;
            double g_16 = 2 * b01 * g_4 + b00 * g_6 + c0px * g_7 + xkxl * g_7;
            double g_17 = xkxl * g_8 + c00x * (c0px * g_7 + 2 * b01 * g_4 + b00 * g_6) + b10 * (c0px * g_6 + 2 * b01 * c0px) + 3 * b00 * g_7;
            double g_18 = 1;
            double g_19 = c00y;
            double g_20 = c00y * c00y + b10;
            double g_21 = c0py;
            double g_22 = c0py * c00y + b00;
            double g_23 = b00 * c00y + b10 * c0py + c00y * g_22;
            double g_24 = c0py * c0py + b01;
            double g_25 = b00 * c0py + b01 * c00y + c0py * g_22;
            double g_26 = 2 * b00 * g_22 + b10 * g_24 + c00y * g_25;
            double g_27 = c0py + ykyl;
            double g_28 = c00y * (c0py + ykyl) + b00;
            double g_29 = b00 * c00y + b10 * c0py + c00y * g_22 + ykyl * g_20;
            double g_30 = c0py * (c0py + ykyl) + b01;
            double g_31 = b00 * c0py + b01 * c00y + c0py * g_22 + ykyl * g_22;
            double g_32 = 2 * b00 * g_22 + b10 * g_24 + c00y * g_25 + ykyl * g_23;
            double g_33 = c0py * (2 * b01 + g_24) + ykyl * g_24;
            double g_34 = 2 * b01 * g_22 + b00 * g_24 + c0py * g_25 + ykyl * g_25;
            double g_35 = ykyl * g_26 + c00y * (c0py * g_25 + 2 * b01 * g_22 + b00 * g_24) + b10 * (c0py * g_24 + 2 * b01 * c0py) + 3 * b00 * g_25;
            double g_36 = weight0 * fac;
            double g_37 = c00z * g_36;
            double g_38 = b10 * g_36 + c00z * g_37;
            double g_39 = c0pz * g_36;
            double g_40 = b00 * g_36 + c0pz * g_37;
            double g_41 = b00 * g_37 + b10 * g_39 + c00z * g_40;
            double g_42 = b01 * g_36 + c0pz * g_39;
            double g_43 = b00 * g_39 + b01 * g_37 + c0pz * g_40;
            double g_44 = 2 * b00 * g_40 + b10 * g_42 + c00z * g_43;
            double g_45 = g_36 * (c0pz + zkzl);
            double g_46 = b00 * g_36 + c0pz * g_37 + zkzl * g_37;
            double g_47 = b00 * g_37 + b10 * g_39 + c00z * g_40 + zkzl * g_38;
            double g_48 = b01 * g_36 + c0pz * g_39 + zkzl * g_39;
            double g_49 = b00 * g_39 + b01 * g_37 + c0pz * g_40 + zkzl * g_40;
            double g_50 = 2 * b00 * g_40 + b10 * g_42 + c00z * g_43 + zkzl * g_41;
            double g_51 = 2 * b01 * g_39 + c0pz * g_42 + zkzl * g_42;
            double g_52 = 2 * b01 * g_40 + b00 * g_42 + c0pz * g_43 + zkzl * g_43;
            double g_53 = zkzl * g_44 + c00z * (c0pz * g_43 + 2 * b01 * g_40 + b00 * g_42) + b10 * (c0pz * g_42 + 2 * b01 * g_39) + 3 * b00 * g_43;
            gout0 += g_17 * g_18 * g_36;
            gout1 += g_16 * g_19 * g_36;
            gout2 += g_16 * g_18 * g_37;
            gout3 += g_15 * g_20 * g_36;
            gout4 += g_15 * g_19 * g_37;
            gout5 += g_15 * g_18 * g_38;
            gout6 += g_14 * g_21 * g_36;
            gout7 += g_13 * g_22 * g_36;
            gout8 += g_13 * g_21 * g_37;
            gout9 += g_12 * g_23 * g_36;
            gout10 += g_12 * g_22 * g_37;
            gout11 += g_12 * g_21 * g_38;
            gout12 += g_14 * g_18 * g_39;
            gout13 += g_13 * g_19 * g_39;
            gout14 += g_13 * g_18 * g_40;
            gout15 += g_12 * g_20 * g_39;
            gout16 += g_12 * g_19 * g_40;
            gout17 += g_12 * g_18 * g_41;
            gout18 += g_11 * g_24 * g_36;
            gout19 += g_10 * g_25 * g_36;
            gout20 += g_10 * g_24 * g_37;
            gout21 += g_9 * g_26 * g_36;
            gout22 += g_9 * g_25 * g_37;
            gout23 += g_9 * g_24 * g_38;
            gout24 += g_11 * g_21 * g_39;
            gout25 += g_10 * g_22 * g_39;
            gout26 += g_10 * g_21 * g_40;
            gout27 += g_9 * g_23 * g_39;
            gout28 += g_9 * g_22 * g_40;
            gout29 += g_9 * g_21 * g_41;
            gout30 += g_11 * g_18 * g_42;
            gout31 += g_10 * g_19 * g_42;
            gout32 += g_10 * g_18 * g_43;
            gout33 += g_9 * g_20 * g_42;
            gout34 += g_9 * g_19 * g_43;
            gout35 += g_9 * g_18 * g_44;
            gout36 += g_8 * g_27 * g_36;
            gout37 += g_7 * g_28 * g_36;
            gout38 += g_7 * g_27 * g_37;
            gout39 += g_6 * g_29 * g_36;
            gout40 += g_6 * g_28 * g_37;
            gout41 += g_6 * g_27 * g_38;
            gout42 += g_5 * g_30 * g_36;
            gout43 += g_4 * g_31 * g_36;
            gout44 += g_4 * g_30 * g_37;
            gout45 += g_3 * g_32 * g_36;
            gout46 += g_3 * g_31 * g_37;
            gout47 += g_3 * g_30 * g_38;
            gout48 += g_5 * g_27 * g_39;
            gout49 += g_4 * g_28 * g_39;
            gout50 += g_4 * g_27 * g_40;
            gout51 += g_3 * g_29 * g_39;
            gout52 += g_3 * g_28 * g_40;
            gout53 += g_3 * g_27 * g_41;
            gout54 += g_2 * g_33 * g_36;
            gout55 += g_1 * g_34 * g_36;
            gout56 += g_1 * g_33 * g_37;
            gout57 += g_0 * g_35 * g_36;
            gout58 += g_0 * g_34 * g_37;
            gout59 += g_0 * g_33 * g_38;
            gout60 += g_2 * g_30 * g_39;
            gout61 += g_1 * g_31 * g_39;
            gout62 += g_1 * g_30 * g_40;
            gout63 += g_0 * g_32 * g_39;
            gout64 += g_0 * g_31 * g_40;
            gout65 += g_0 * g_30 * g_41;
            gout66 += g_2 * g_27 * g_42;
            gout67 += g_1 * g_28 * g_42;
            gout68 += g_1 * g_27 * g_43;
            gout69 += g_0 * g_29 * g_42;
            gout70 += g_0 * g_28 * g_43;
            gout71 += g_0 * g_27 * g_44;
            gout72 += g_8 * g_18 * g_45;
            gout73 += g_7 * g_19 * g_45;
            gout74 += g_7 * g_18 * g_46;
            gout75 += g_6 * g_20 * g_45;
            gout76 += g_6 * g_19 * g_46;
            gout77 += g_6 * g_18 * g_47;
            gout78 += g_5 * g_21 * g_45;
            gout79 += g_4 * g_22 * g_45;
            gout80 += g_4 * g_21 * g_46;
            gout81 += g_3 * g_23 * g_45;
            gout82 += g_3 * g_22 * g_46;
            gout83 += g_3 * g_21 * g_47;
            gout84 += g_5 * g_18 * g_48;
            gout85 += g_4 * g_19 * g_48;
            gout86 += g_4 * g_18 * g_49;
            gout87 += g_3 * g_20 * g_48;
            gout88 += g_3 * g_19 * g_49;
            gout89 += g_3 * g_18 * g_50;
            gout90 += g_2 * g_24 * g_45;
            gout91 += g_1 * g_25 * g_45;
            gout92 += g_1 * g_24 * g_46;
            gout93 += g_0 * g_26 * g_45;
            gout94 += g_0 * g_25 * g_46;
            gout95 += g_0 * g_24 * g_47;
            gout96 += g_2 * g_21 * g_48;
            gout97 += g_1 * g_22 * g_48;
            gout98 += g_1 * g_21 * g_49;
            gout99 += g_0 * g_23 * g_48;
            gout100 += g_0 * g_22 * g_49;
            gout101 += g_0 * g_21 * g_50;
            gout102 += g_2 * g_18 * g_51;
            gout103 += g_1 * g_19 * g_51;
            gout104 += g_1 * g_18 * g_52;
            gout105 += g_0 * g_20 * g_51;
            gout106 += g_0 * g_19 * g_52;
            gout107 += g_0 * g_18 * g_53;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[3] = gout3;
    //eri_ji[3*jstride] = gout3;
    eri_ij[4] = gout4;
    //eri_ji[4*jstride] = gout4;
    eri_ij[5] = gout5;
    //eri_ji[5*jstride] = gout5;
    eri_ij[1*kstride] = gout6;
    //eri_ji[1*kstride] = gout6;
    eri_ij[1+1*kstride] = gout7;
    //eri_ji[1*jstride+1*kstride] = gout7;
    eri_ij[2+1*kstride] = gout8;
    //eri_ji[2*jstride+1*kstride] = gout8;
    eri_ij[3+1*kstride] = gout9;
    //eri_ji[3*jstride+1*kstride] = gout9;
    eri_ij[4+1*kstride] = gout10;
    //eri_ji[4*jstride+1*kstride] = gout10;
    eri_ij[5+1*kstride] = gout11;
    //eri_ji[5*jstride+1*kstride] = gout11;
    eri_ij[2*kstride] = gout12;
    //eri_ji[2*kstride] = gout12;
    eri_ij[1+2*kstride] = gout13;
    //eri_ji[1*jstride+2*kstride] = gout13;
    eri_ij[2+2*kstride] = gout14;
    //eri_ji[2*jstride+2*kstride] = gout14;
    eri_ij[3+2*kstride] = gout15;
    //eri_ji[3*jstride+2*kstride] = gout15;
    eri_ij[4+2*kstride] = gout16;
    //eri_ji[4*jstride+2*kstride] = gout16;
    eri_ij[5+2*kstride] = gout17;
    //eri_ji[5*jstride+2*kstride] = gout17;
    eri_ij[3*kstride] = gout18;
    //eri_ji[3*kstride] = gout18;
    eri_ij[1+3*kstride] = gout19;
    //eri_ji[1*jstride+3*kstride] = gout19;
    eri_ij[2+3*kstride] = gout20;
    //eri_ji[2*jstride+3*kstride] = gout20;
    eri_ij[3+3*kstride] = gout21;
    //eri_ji[3*jstride+3*kstride] = gout21;
    eri_ij[4+3*kstride] = gout22;
    //eri_ji[4*jstride+3*kstride] = gout22;
    eri_ij[5+3*kstride] = gout23;
    //eri_ji[5*jstride+3*kstride] = gout23;
    eri_ij[4*kstride] = gout24;
    //eri_ji[4*kstride] = gout24;
    eri_ij[1+4*kstride] = gout25;
    //eri_ji[1*jstride+4*kstride] = gout25;
    eri_ij[2+4*kstride] = gout26;
    //eri_ji[2*jstride+4*kstride] = gout26;
    eri_ij[3+4*kstride] = gout27;
    //eri_ji[3*jstride+4*kstride] = gout27;
    eri_ij[4+4*kstride] = gout28;
    //eri_ji[4*jstride+4*kstride] = gout28;
    eri_ij[5+4*kstride] = gout29;
    //eri_ji[5*jstride+4*kstride] = gout29;
    eri_ij[5*kstride] = gout30;
    //eri_ji[5*kstride] = gout30;
    eri_ij[1+5*kstride] = gout31;
    //eri_ji[1*jstride+5*kstride] = gout31;
    eri_ij[2+5*kstride] = gout32;
    //eri_ji[2*jstride+5*kstride] = gout32;
    eri_ij[3+5*kstride] = gout33;
    //eri_ji[3*jstride+5*kstride] = gout33;
    eri_ij[4+5*kstride] = gout34;
    //eri_ji[4*jstride+5*kstride] = gout34;
    eri_ij[5+5*kstride] = gout35;
    //eri_ji[5*jstride+5*kstride] = gout35;
    eri_ij[1*lstride] = gout36;
    //eri_ji[1*lstride] = gout36;
    eri_ij[1+1*lstride] = gout37;
    //eri_ji[1*jstride+1*lstride] = gout37;
    eri_ij[2+1*lstride] = gout38;
    //eri_ji[2*jstride+1*lstride] = gout38;
    eri_ij[3+1*lstride] = gout39;
    //eri_ji[3*jstride+1*lstride] = gout39;
    eri_ij[4+1*lstride] = gout40;
    //eri_ji[4*jstride+1*lstride] = gout40;
    eri_ij[5+1*lstride] = gout41;
    //eri_ji[5*jstride+1*lstride] = gout41;
    eri_ij[1*kstride+1*lstride] = gout42;
    //eri_ji[1*kstride+1*lstride] = gout42;
    eri_ij[1+1*kstride+1*lstride] = gout43;
    //eri_ji[1*jstride+1*kstride+1*lstride] = gout43;
    eri_ij[2+1*kstride+1*lstride] = gout44;
    //eri_ji[2*jstride+1*kstride+1*lstride] = gout44;
    eri_ij[3+1*kstride+1*lstride] = gout45;
    //eri_ji[3*jstride+1*kstride+1*lstride] = gout45;
    eri_ij[4+1*kstride+1*lstride] = gout46;
    //eri_ji[4*jstride+1*kstride+1*lstride] = gout46;
    eri_ij[5+1*kstride+1*lstride] = gout47;
    //eri_ji[5*jstride+1*kstride+1*lstride] = gout47;
    eri_ij[2*kstride+1*lstride] = gout48;
    //eri_ji[2*kstride+1*lstride] = gout48;
    eri_ij[1+2*kstride+1*lstride] = gout49;
    //eri_ji[1*jstride+2*kstride+1*lstride] = gout49;
    eri_ij[2+2*kstride+1*lstride] = gout50;
    //eri_ji[2*jstride+2*kstride+1*lstride] = gout50;
    eri_ij[3+2*kstride+1*lstride] = gout51;
    //eri_ji[3*jstride+2*kstride+1*lstride] = gout51;
    eri_ij[4+2*kstride+1*lstride] = gout52;
    //eri_ji[4*jstride+2*kstride+1*lstride] = gout52;
    eri_ij[5+2*kstride+1*lstride] = gout53;
    //eri_ji[5*jstride+2*kstride+1*lstride] = gout53;
    eri_ij[3*kstride+1*lstride] = gout54;
    //eri_ji[3*kstride+1*lstride] = gout54;
    eri_ij[1+3*kstride+1*lstride] = gout55;
    //eri_ji[1*jstride+3*kstride+1*lstride] = gout55;
    eri_ij[2+3*kstride+1*lstride] = gout56;
    //eri_ji[2*jstride+3*kstride+1*lstride] = gout56;
    eri_ij[3+3*kstride+1*lstride] = gout57;
    //eri_ji[3*jstride+3*kstride+1*lstride] = gout57;
    eri_ij[4+3*kstride+1*lstride] = gout58;
    //eri_ji[4*jstride+3*kstride+1*lstride] = gout58;
    eri_ij[5+3*kstride+1*lstride] = gout59;
    //eri_ji[5*jstride+3*kstride+1*lstride] = gout59;
    eri_ij[4*kstride+1*lstride] = gout60;
    //eri_ji[4*kstride+1*lstride] = gout60;
    eri_ij[1+4*kstride+1*lstride] = gout61;
    //eri_ji[1*jstride+4*kstride+1*lstride] = gout61;
    eri_ij[2+4*kstride+1*lstride] = gout62;
    //eri_ji[2*jstride+4*kstride+1*lstride] = gout62;
    eri_ij[3+4*kstride+1*lstride] = gout63;
    //eri_ji[3*jstride+4*kstride+1*lstride] = gout63;
    eri_ij[4+4*kstride+1*lstride] = gout64;
    //eri_ji[4*jstride+4*kstride+1*lstride] = gout64;
    eri_ij[5+4*kstride+1*lstride] = gout65;
    //eri_ji[5*jstride+4*kstride+1*lstride] = gout65;
    eri_ij[5*kstride+1*lstride] = gout66;
    //eri_ji[5*kstride+1*lstride] = gout66;
    eri_ij[1+5*kstride+1*lstride] = gout67;
    //eri_ji[1*jstride+5*kstride+1*lstride] = gout67;
    eri_ij[2+5*kstride+1*lstride] = gout68;
    //eri_ji[2*jstride+5*kstride+1*lstride] = gout68;
    eri_ij[3+5*kstride+1*lstride] = gout69;
    //eri_ji[3*jstride+5*kstride+1*lstride] = gout69;
    eri_ij[4+5*kstride+1*lstride] = gout70;
    //eri_ji[4*jstride+5*kstride+1*lstride] = gout70;
    eri_ij[5+5*kstride+1*lstride] = gout71;
    //eri_ji[5*jstride+5*kstride+1*lstride] = gout71;
    eri_ij[2*lstride] = gout72;
    //eri_ji[2*lstride] = gout72;
    eri_ij[1+2*lstride] = gout73;
    //eri_ji[1*jstride+2*lstride] = gout73;
    eri_ij[2+2*lstride] = gout74;
    //eri_ji[2*jstride+2*lstride] = gout74;
    eri_ij[3+2*lstride] = gout75;
    //eri_ji[3*jstride+2*lstride] = gout75;
    eri_ij[4+2*lstride] = gout76;
    //eri_ji[4*jstride+2*lstride] = gout76;
    eri_ij[5+2*lstride] = gout77;
    //eri_ji[5*jstride+2*lstride] = gout77;
    eri_ij[1*kstride+2*lstride] = gout78;
    //eri_ji[1*kstride+2*lstride] = gout78;
    eri_ij[1+1*kstride+2*lstride] = gout79;
    //eri_ji[1*jstride+1*kstride+2*lstride] = gout79;
    eri_ij[2+1*kstride+2*lstride] = gout80;
    //eri_ji[2*jstride+1*kstride+2*lstride] = gout80;
    eri_ij[3+1*kstride+2*lstride] = gout81;
    //eri_ji[3*jstride+1*kstride+2*lstride] = gout81;
    eri_ij[4+1*kstride+2*lstride] = gout82;
    //eri_ji[4*jstride+1*kstride+2*lstride] = gout82;
    eri_ij[5+1*kstride+2*lstride] = gout83;
    //eri_ji[5*jstride+1*kstride+2*lstride] = gout83;
    eri_ij[2*kstride+2*lstride] = gout84;
    //eri_ji[2*kstride+2*lstride] = gout84;
    eri_ij[1+2*kstride+2*lstride] = gout85;
    //eri_ji[1*jstride+2*kstride+2*lstride] = gout85;
    eri_ij[2+2*kstride+2*lstride] = gout86;
    //eri_ji[2*jstride+2*kstride+2*lstride] = gout86;
    eri_ij[3+2*kstride+2*lstride] = gout87;
    //eri_ji[3*jstride+2*kstride+2*lstride] = gout87;
    eri_ij[4+2*kstride+2*lstride] = gout88;
    //eri_ji[4*jstride+2*kstride+2*lstride] = gout88;
    eri_ij[5+2*kstride+2*lstride] = gout89;
    //eri_ji[5*jstride+2*kstride+2*lstride] = gout89;
    eri_ij[3*kstride+2*lstride] = gout90;
    //eri_ji[3*kstride+2*lstride] = gout90;
    eri_ij[1+3*kstride+2*lstride] = gout91;
    //eri_ji[1*jstride+3*kstride+2*lstride] = gout91;
    eri_ij[2+3*kstride+2*lstride] = gout92;
    //eri_ji[2*jstride+3*kstride+2*lstride] = gout92;
    eri_ij[3+3*kstride+2*lstride] = gout93;
    //eri_ji[3*jstride+3*kstride+2*lstride] = gout93;
    eri_ij[4+3*kstride+2*lstride] = gout94;
    //eri_ji[4*jstride+3*kstride+2*lstride] = gout94;
    eri_ij[5+3*kstride+2*lstride] = gout95;
    //eri_ji[5*jstride+3*kstride+2*lstride] = gout95;
    eri_ij[4*kstride+2*lstride] = gout96;
    //eri_ji[4*kstride+2*lstride] = gout96;
    eri_ij[1+4*kstride+2*lstride] = gout97;
    //eri_ji[1*jstride+4*kstride+2*lstride] = gout97;
    eri_ij[2+4*kstride+2*lstride] = gout98;
    //eri_ji[2*jstride+4*kstride+2*lstride] = gout98;
    eri_ij[3+4*kstride+2*lstride] = gout99;
    //eri_ji[3*jstride+4*kstride+2*lstride] = gout99;
    eri_ij[4+4*kstride+2*lstride] = gout100;
    //eri_ji[4*jstride+4*kstride+2*lstride] = gout100;
    eri_ij[5+4*kstride+2*lstride] = gout101;
    //eri_ji[5*jstride+4*kstride+2*lstride] = gout101;
    eri_ij[5*kstride+2*lstride] = gout102;
    //eri_ji[5*kstride+2*lstride] = gout102;
    eri_ij[1+5*kstride+2*lstride] = gout103;
    //eri_ji[1*jstride+5*kstride+2*lstride] = gout103;
    eri_ij[2+5*kstride+2*lstride] = gout104;
    //eri_ji[2*jstride+5*kstride+2*lstride] = gout104;
    eri_ij[3+5*kstride+2*lstride] = gout105;
    //eri_ji[3*jstride+5*kstride+2*lstride] = gout105;
    eri_ij[4+5*kstride+2*lstride] = gout106;
    //eri_ji[4*jstride+5*kstride+2*lstride] = gout106;
    eri_ij[5+5*kstride+2*lstride] = gout107;
    //eri_ji[5*jstride+5*kstride+2*lstride] = gout107;
}

__global__
static void GINTfill_int2e_kernel2030(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double gout36 = 0;
    double gout37 = 0;
    double gout38 = 0;
    double gout39 = 0;
    double gout40 = 0;
    double gout41 = 0;
    double gout42 = 0;
    double gout43 = 0;
    double gout44 = 0;
    double gout45 = 0;
    double gout46 = 0;
    double gout47 = 0;
    double gout48 = 0;
    double gout49 = 0;
    double gout50 = 0;
    double gout51 = 0;
    double gout52 = 0;
    double gout53 = 0;
    double gout54 = 0;
    double gout55 = 0;
    double gout56 = 0;
    double gout57 = 0;
    double gout58 = 0;
    double gout59 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double b10 = b00 + tmp4 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double b01 = b00 + tmp4 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c00x * c00x + b10;
            double g_3 = c0px;
            double g_4 = c0px * c00x + b00;
            double g_5 = b00 * c00x + b10 * c0px + c00x * g_4;
            double g_6 = c0px * c0px + b01;
            double g_7 = b00 * c0px + b01 * c00x + c0px * g_4;
            double g_8 = 2 * b00 * g_4 + b10 * g_6 + c00x * g_7;
            double g_9 = c0px * (2 * b01 + g_6);
            double g_10 = 2 * b01 * g_4 + b00 * g_6 + c0px * g_7;
            double g_11 = 3 * b00 * g_7 + b10 * g_9 + c00x * g_10;
            double g_12 = 1;
            double g_13 = c00y;
            double g_14 = c00y * c00y + b10;
            double g_15 = c0py;
            double g_16 = c0py * c00y + b00;
            double g_17 = b00 * c00y + b10 * c0py + c00y * g_16;
            double g_18 = c0py * c0py + b01;
            double g_19 = b00 * c0py + b01 * c00y + c0py * g_16;
            double g_20 = 2 * b00 * g_16 + b10 * g_18 + c00y * g_19;
            double g_21 = c0py * (2 * b01 + g_18);
            double g_22 = 2 * b01 * g_16 + b00 * g_18 + c0py * g_19;
            double g_23 = 3 * b00 * g_19 + b10 * g_21 + c00y * g_22;
            double g_24 = weight0 * fac;
            double g_25 = c00z * g_24;
            double g_26 = b10 * g_24 + c00z * g_25;
            double g_27 = c0pz * g_24;
            double g_28 = b00 * g_24 + c0pz * g_25;
            double g_29 = b00 * g_25 + b10 * g_27 + c00z * g_28;
            double g_30 = b01 * g_24 + c0pz * g_27;
            double g_31 = b00 * g_27 + b01 * g_25 + c0pz * g_28;
            double g_32 = 2 * b00 * g_28 + b10 * g_30 + c00z * g_31;
            double g_33 = 2 * b01 * g_27 + c0pz * g_30;
            double g_34 = 2 * b01 * g_28 + b00 * g_30 + c0pz * g_31;
            double g_35 = 3 * b00 * g_31 + b10 * g_33 + c00z * g_34;
            gout0 += g_11 * g_12 * g_24;
            gout1 += g_10 * g_13 * g_24;
            gout2 += g_10 * g_12 * g_25;
            gout3 += g_9 * g_14 * g_24;
            gout4 += g_9 * g_13 * g_25;
            gout5 += g_9 * g_12 * g_26;
            gout6 += g_8 * g_15 * g_24;
            gout7 += g_7 * g_16 * g_24;
            gout8 += g_7 * g_15 * g_25;
            gout9 += g_6 * g_17 * g_24;
            gout10 += g_6 * g_16 * g_25;
            gout11 += g_6 * g_15 * g_26;
            gout12 += g_8 * g_12 * g_27;
            gout13 += g_7 * g_13 * g_27;
            gout14 += g_7 * g_12 * g_28;
            gout15 += g_6 * g_14 * g_27;
            gout16 += g_6 * g_13 * g_28;
            gout17 += g_6 * g_12 * g_29;
            gout18 += g_5 * g_18 * g_24;
            gout19 += g_4 * g_19 * g_24;
            gout20 += g_4 * g_18 * g_25;
            gout21 += g_3 * g_20 * g_24;
            gout22 += g_3 * g_19 * g_25;
            gout23 += g_3 * g_18 * g_26;
            gout24 += g_5 * g_15 * g_27;
            gout25 += g_4 * g_16 * g_27;
            gout26 += g_4 * g_15 * g_28;
            gout27 += g_3 * g_17 * g_27;
            gout28 += g_3 * g_16 * g_28;
            gout29 += g_3 * g_15 * g_29;
            gout30 += g_5 * g_12 * g_30;
            gout31 += g_4 * g_13 * g_30;
            gout32 += g_4 * g_12 * g_31;
            gout33 += g_3 * g_14 * g_30;
            gout34 += g_3 * g_13 * g_31;
            gout35 += g_3 * g_12 * g_32;
            gout36 += g_2 * g_21 * g_24;
            gout37 += g_1 * g_22 * g_24;
            gout38 += g_1 * g_21 * g_25;
            gout39 += g_0 * g_23 * g_24;
            gout40 += g_0 * g_22 * g_25;
            gout41 += g_0 * g_21 * g_26;
            gout42 += g_2 * g_18 * g_27;
            gout43 += g_1 * g_19 * g_27;
            gout44 += g_1 * g_18 * g_28;
            gout45 += g_0 * g_20 * g_27;
            gout46 += g_0 * g_19 * g_28;
            gout47 += g_0 * g_18 * g_29;
            gout48 += g_2 * g_15 * g_30;
            gout49 += g_1 * g_16 * g_30;
            gout50 += g_1 * g_15 * g_31;
            gout51 += g_0 * g_17 * g_30;
            gout52 += g_0 * g_16 * g_31;
            gout53 += g_0 * g_15 * g_32;
            gout54 += g_2 * g_12 * g_33;
            gout55 += g_1 * g_13 * g_33;
            gout56 += g_1 * g_12 * g_34;
            gout57 += g_0 * g_14 * g_33;
            gout58 += g_0 * g_13 * g_34;
            gout59 += g_0 * g_12 * g_35;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[3] = gout3;
    //eri_ji[3*jstride] = gout3;
    eri_ij[4] = gout4;
    //eri_ji[4*jstride] = gout4;
    eri_ij[5] = gout5;
    //eri_ji[5*jstride] = gout5;
    eri_ij[1*kstride] = gout6;
    //eri_ji[1*kstride] = gout6;
    eri_ij[1+1*kstride] = gout7;
    //eri_ji[1*jstride+1*kstride] = gout7;
    eri_ij[2+1*kstride] = gout8;
    //eri_ji[2*jstride+1*kstride] = gout8;
    eri_ij[3+1*kstride] = gout9;
    //eri_ji[3*jstride+1*kstride] = gout9;
    eri_ij[4+1*kstride] = gout10;
    //eri_ji[4*jstride+1*kstride] = gout10;
    eri_ij[5+1*kstride] = gout11;
    //eri_ji[5*jstride+1*kstride] = gout11;
    eri_ij[2*kstride] = gout12;
    //eri_ji[2*kstride] = gout12;
    eri_ij[1+2*kstride] = gout13;
    //eri_ji[1*jstride+2*kstride] = gout13;
    eri_ij[2+2*kstride] = gout14;
    //eri_ji[2*jstride+2*kstride] = gout14;
    eri_ij[3+2*kstride] = gout15;
    //eri_ji[3*jstride+2*kstride] = gout15;
    eri_ij[4+2*kstride] = gout16;
    //eri_ji[4*jstride+2*kstride] = gout16;
    eri_ij[5+2*kstride] = gout17;
    //eri_ji[5*jstride+2*kstride] = gout17;
    eri_ij[3*kstride] = gout18;
    //eri_ji[3*kstride] = gout18;
    eri_ij[1+3*kstride] = gout19;
    //eri_ji[1*jstride+3*kstride] = gout19;
    eri_ij[2+3*kstride] = gout20;
    //eri_ji[2*jstride+3*kstride] = gout20;
    eri_ij[3+3*kstride] = gout21;
    //eri_ji[3*jstride+3*kstride] = gout21;
    eri_ij[4+3*kstride] = gout22;
    //eri_ji[4*jstride+3*kstride] = gout22;
    eri_ij[5+3*kstride] = gout23;
    //eri_ji[5*jstride+3*kstride] = gout23;
    eri_ij[4*kstride] = gout24;
    //eri_ji[4*kstride] = gout24;
    eri_ij[1+4*kstride] = gout25;
    //eri_ji[1*jstride+4*kstride] = gout25;
    eri_ij[2+4*kstride] = gout26;
    //eri_ji[2*jstride+4*kstride] = gout26;
    eri_ij[3+4*kstride] = gout27;
    //eri_ji[3*jstride+4*kstride] = gout27;
    eri_ij[4+4*kstride] = gout28;
    //eri_ji[4*jstride+4*kstride] = gout28;
    eri_ij[5+4*kstride] = gout29;
    //eri_ji[5*jstride+4*kstride] = gout29;
    eri_ij[5*kstride] = gout30;
    //eri_ji[5*kstride] = gout30;
    eri_ij[1+5*kstride] = gout31;
    //eri_ji[1*jstride+5*kstride] = gout31;
    eri_ij[2+5*kstride] = gout32;
    //eri_ji[2*jstride+5*kstride] = gout32;
    eri_ij[3+5*kstride] = gout33;
    //eri_ji[3*jstride+5*kstride] = gout33;
    eri_ij[4+5*kstride] = gout34;
    //eri_ji[4*jstride+5*kstride] = gout34;
    eri_ij[5+5*kstride] = gout35;
    //eri_ji[5*jstride+5*kstride] = gout35;
    eri_ij[6*kstride] = gout36;
    //eri_ji[6*kstride] = gout36;
    eri_ij[1+6*kstride] = gout37;
    //eri_ji[1*jstride+6*kstride] = gout37;
    eri_ij[2+6*kstride] = gout38;
    //eri_ji[2*jstride+6*kstride] = gout38;
    eri_ij[3+6*kstride] = gout39;
    //eri_ji[3*jstride+6*kstride] = gout39;
    eri_ij[4+6*kstride] = gout40;
    //eri_ji[4*jstride+6*kstride] = gout40;
    eri_ij[5+6*kstride] = gout41;
    //eri_ji[5*jstride+6*kstride] = gout41;
    eri_ij[7*kstride] = gout42;
    //eri_ji[7*kstride] = gout42;
    eri_ij[1+7*kstride] = gout43;
    //eri_ji[1*jstride+7*kstride] = gout43;
    eri_ij[2+7*kstride] = gout44;
    //eri_ji[2*jstride+7*kstride] = gout44;
    eri_ij[3+7*kstride] = gout45;
    //eri_ji[3*jstride+7*kstride] = gout45;
    eri_ij[4+7*kstride] = gout46;
    //eri_ji[4*jstride+7*kstride] = gout46;
    eri_ij[5+7*kstride] = gout47;
    //eri_ji[5*jstride+7*kstride] = gout47;
    eri_ij[8*kstride] = gout48;
    //eri_ji[8*kstride] = gout48;
    eri_ij[1+8*kstride] = gout49;
    //eri_ji[1*jstride+8*kstride] = gout49;
    eri_ij[2+8*kstride] = gout50;
    //eri_ji[2*jstride+8*kstride] = gout50;
    eri_ij[3+8*kstride] = gout51;
    //eri_ji[3*jstride+8*kstride] = gout51;
    eri_ij[4+8*kstride] = gout52;
    //eri_ji[4*jstride+8*kstride] = gout52;
    eri_ij[5+8*kstride] = gout53;
    //eri_ji[5*jstride+8*kstride] = gout53;
    eri_ij[9*kstride] = gout54;
    //eri_ji[9*kstride] = gout54;
    eri_ij[1+9*kstride] = gout55;
    //eri_ji[1*jstride+9*kstride] = gout55;
    eri_ij[2+9*kstride] = gout56;
    //eri_ji[2*jstride+9*kstride] = gout56;
    eri_ij[3+9*kstride] = gout57;
    //eri_ji[3*jstride+9*kstride] = gout57;
    eri_ij[4+9*kstride] = gout58;
    //eri_ji[4*jstride+9*kstride] = gout58;
    eri_ij[5+9*kstride] = gout59;
    //eri_ji[5*jstride+9*kstride] = gout59;
}

__global__
static void GINTfill_int2e_kernel2110(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double gout36 = 0;
    double gout37 = 0;
    double gout38 = 0;
    double gout39 = 0;
    double gout40 = 0;
    double gout41 = 0;
    double gout42 = 0;
    double gout43 = 0;
    double gout44 = 0;
    double gout45 = 0;
    double gout46 = 0;
    double gout47 = 0;
    double gout48 = 0;
    double gout49 = 0;
    double gout50 = 0;
    double gout51 = 0;
    double gout52 = 0;
    double gout53 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xixj = xi - bas_x[jsh];
    double yiyj = yi - bas_y[jsh];
    double zizj = zi - bas_z[jsh];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double b10 = b00 + tmp4 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c00x * c00x + b10;
            double g_3 = c00x + xixj;
            double g_4 = c00x * (c00x + xixj) + b10;
            double g_5 = c00x * (2 * b10 + g_2) + xixj * g_2;
            double g_6 = c0px;
            double g_7 = c0px * c00x + b00;
            double g_8 = b00 * c00x + b10 * c0px + c00x * g_7;
            double g_9 = c0px * (c00x + xixj) + b00;
            double g_10 = b00 * c00x + b10 * c0px + c00x * g_7 + xixj * g_7;
            double g_11 = 2 * b10 * g_7 + b00 * g_2 + c00x * g_8 + xixj * g_8;
            double g_12 = 1;
            double g_13 = c00y;
            double g_14 = c00y * c00y + b10;
            double g_15 = c00y + yiyj;
            double g_16 = c00y * (c00y + yiyj) + b10;
            double g_17 = c00y * (2 * b10 + g_14) + yiyj * g_14;
            double g_18 = c0py;
            double g_19 = c0py * c00y + b00;
            double g_20 = b00 * c00y + b10 * c0py + c00y * g_19;
            double g_21 = c0py * (c00y + yiyj) + b00;
            double g_22 = b00 * c00y + b10 * c0py + c00y * g_19 + yiyj * g_19;
            double g_23 = 2 * b10 * g_19 + b00 * g_14 + c00y * g_20 + yiyj * g_20;
            double g_24 = weight0 * fac;
            double g_25 = c00z * g_24;
            double g_26 = b10 * g_24 + c00z * g_25;
            double g_27 = g_24 * (c00z + zizj);
            double g_28 = b10 * g_24 + c00z * g_25 + zizj * g_25;
            double g_29 = 2 * b10 * g_25 + c00z * g_26 + zizj * g_26;
            double g_30 = c0pz * g_24;
            double g_31 = b00 * g_24 + c0pz * g_25;
            double g_32 = b00 * g_25 + b10 * g_30 + c00z * g_31;
            double g_33 = b00 * g_24 + c0pz * g_25 + zizj * g_30;
            double g_34 = b00 * g_25 + b10 * g_30 + c00z * g_31 + zizj * g_31;
            double g_35 = 2 * b10 * g_31 + b00 * g_26 + c00z * g_32 + zizj * g_32;
            gout0 += g_11 * g_12 * g_24;
            gout1 += g_10 * g_13 * g_24;
            gout2 += g_10 * g_12 * g_25;
            gout3 += g_9 * g_14 * g_24;
            gout4 += g_9 * g_13 * g_25;
            gout5 += g_9 * g_12 * g_26;
            gout6 += g_8 * g_15 * g_24;
            gout7 += g_7 * g_16 * g_24;
            gout8 += g_7 * g_15 * g_25;
            gout9 += g_6 * g_17 * g_24;
            gout10 += g_6 * g_16 * g_25;
            gout11 += g_6 * g_15 * g_26;
            gout12 += g_8 * g_12 * g_27;
            gout13 += g_7 * g_13 * g_27;
            gout14 += g_7 * g_12 * g_28;
            gout15 += g_6 * g_14 * g_27;
            gout16 += g_6 * g_13 * g_28;
            gout17 += g_6 * g_12 * g_29;
            gout18 += g_5 * g_18 * g_24;
            gout19 += g_4 * g_19 * g_24;
            gout20 += g_4 * g_18 * g_25;
            gout21 += g_3 * g_20 * g_24;
            gout22 += g_3 * g_19 * g_25;
            gout23 += g_3 * g_18 * g_26;
            gout24 += g_2 * g_21 * g_24;
            gout25 += g_1 * g_22 * g_24;
            gout26 += g_1 * g_21 * g_25;
            gout27 += g_0 * g_23 * g_24;
            gout28 += g_0 * g_22 * g_25;
            gout29 += g_0 * g_21 * g_26;
            gout30 += g_2 * g_18 * g_27;
            gout31 += g_1 * g_19 * g_27;
            gout32 += g_1 * g_18 * g_28;
            gout33 += g_0 * g_20 * g_27;
            gout34 += g_0 * g_19 * g_28;
            gout35 += g_0 * g_18 * g_29;
            gout36 += g_5 * g_12 * g_30;
            gout37 += g_4 * g_13 * g_30;
            gout38 += g_4 * g_12 * g_31;
            gout39 += g_3 * g_14 * g_30;
            gout40 += g_3 * g_13 * g_31;
            gout41 += g_3 * g_12 * g_32;
            gout42 += g_2 * g_15 * g_30;
            gout43 += g_1 * g_16 * g_30;
            gout44 += g_1 * g_15 * g_31;
            gout45 += g_0 * g_17 * g_30;
            gout46 += g_0 * g_16 * g_31;
            gout47 += g_0 * g_15 * g_32;
            gout48 += g_2 * g_12 * g_33;
            gout49 += g_1 * g_13 * g_33;
            gout50 += g_1 * g_12 * g_34;
            gout51 += g_0 * g_14 * g_33;
            gout52 += g_0 * g_13 * g_34;
            gout53 += g_0 * g_12 * g_35;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[3] = gout3;
    //eri_ji[3*jstride] = gout3;
    eri_ij[4] = gout4;
    //eri_ji[4*jstride] = gout4;
    eri_ij[5] = gout5;
    //eri_ji[5*jstride] = gout5;
    eri_ij[1*jstride] = gout6;
    //eri_ji[1] = gout6;
    eri_ij[1+1*jstride] = gout7;
    //eri_ji[1*jstride+1] = gout7;
    eri_ij[2+1*jstride] = gout8;
    //eri_ji[2*jstride+1] = gout8;
    eri_ij[3+1*jstride] = gout9;
    //eri_ji[3*jstride+1] = gout9;
    eri_ij[4+1*jstride] = gout10;
    //eri_ji[4*jstride+1] = gout10;
    eri_ij[5+1*jstride] = gout11;
    //eri_ji[5*jstride+1] = gout11;
    eri_ij[2*jstride] = gout12;
    //eri_ji[2] = gout12;
    eri_ij[1+2*jstride] = gout13;
    //eri_ji[1*jstride+2] = gout13;
    eri_ij[2+2*jstride] = gout14;
    //eri_ji[2*jstride+2] = gout14;
    eri_ij[3+2*jstride] = gout15;
    //eri_ji[3*jstride+2] = gout15;
    eri_ij[4+2*jstride] = gout16;
    //eri_ji[4*jstride+2] = gout16;
    eri_ij[5+2*jstride] = gout17;
    //eri_ji[5*jstride+2] = gout17;
    eri_ij[1*kstride] = gout18;
    //eri_ji[1*kstride] = gout18;
    eri_ij[1+1*kstride] = gout19;
    //eri_ji[1*jstride+1*kstride] = gout19;
    eri_ij[2+1*kstride] = gout20;
    //eri_ji[2*jstride+1*kstride] = gout20;
    eri_ij[3+1*kstride] = gout21;
    //eri_ji[3*jstride+1*kstride] = gout21;
    eri_ij[4+1*kstride] = gout22;
    //eri_ji[4*jstride+1*kstride] = gout22;
    eri_ij[5+1*kstride] = gout23;
    //eri_ji[5*jstride+1*kstride] = gout23;
    eri_ij[1*jstride+1*kstride] = gout24;
    //eri_ji[1+1*kstride] = gout24;
    eri_ij[1+1*jstride+1*kstride] = gout25;
    //eri_ji[1*jstride+1+1*kstride] = gout25;
    eri_ij[2+1*jstride+1*kstride] = gout26;
    //eri_ji[2*jstride+1+1*kstride] = gout26;
    eri_ij[3+1*jstride+1*kstride] = gout27;
    //eri_ji[3*jstride+1+1*kstride] = gout27;
    eri_ij[4+1*jstride+1*kstride] = gout28;
    //eri_ji[4*jstride+1+1*kstride] = gout28;
    eri_ij[5+1*jstride+1*kstride] = gout29;
    //eri_ji[5*jstride+1+1*kstride] = gout29;
    eri_ij[2*jstride+1*kstride] = gout30;
    //eri_ji[2+1*kstride] = gout30;
    eri_ij[1+2*jstride+1*kstride] = gout31;
    //eri_ji[1*jstride+2+1*kstride] = gout31;
    eri_ij[2+2*jstride+1*kstride] = gout32;
    //eri_ji[2*jstride+2+1*kstride] = gout32;
    eri_ij[3+2*jstride+1*kstride] = gout33;
    //eri_ji[3*jstride+2+1*kstride] = gout33;
    eri_ij[4+2*jstride+1*kstride] = gout34;
    //eri_ji[4*jstride+2+1*kstride] = gout34;
    eri_ij[5+2*jstride+1*kstride] = gout35;
    //eri_ji[5*jstride+2+1*kstride] = gout35;
    eri_ij[2*kstride] = gout36;
    //eri_ji[2*kstride] = gout36;
    eri_ij[1+2*kstride] = gout37;
    //eri_ji[1*jstride+2*kstride] = gout37;
    eri_ij[2+2*kstride] = gout38;
    //eri_ji[2*jstride+2*kstride] = gout38;
    eri_ij[3+2*kstride] = gout39;
    //eri_ji[3*jstride+2*kstride] = gout39;
    eri_ij[4+2*kstride] = gout40;
    //eri_ji[4*jstride+2*kstride] = gout40;
    eri_ij[5+2*kstride] = gout41;
    //eri_ji[5*jstride+2*kstride] = gout41;
    eri_ij[1*jstride+2*kstride] = gout42;
    //eri_ji[1+2*kstride] = gout42;
    eri_ij[1+1*jstride+2*kstride] = gout43;
    //eri_ji[1*jstride+1+2*kstride] = gout43;
    eri_ij[2+1*jstride+2*kstride] = gout44;
    //eri_ji[2*jstride+1+2*kstride] = gout44;
    eri_ij[3+1*jstride+2*kstride] = gout45;
    //eri_ji[3*jstride+1+2*kstride] = gout45;
    eri_ij[4+1*jstride+2*kstride] = gout46;
    //eri_ji[4*jstride+1+2*kstride] = gout46;
    eri_ij[5+1*jstride+2*kstride] = gout47;
    //eri_ji[5*jstride+1+2*kstride] = gout47;
    eri_ij[2*jstride+2*kstride] = gout48;
    //eri_ji[2+2*kstride] = gout48;
    eri_ij[1+2*jstride+2*kstride] = gout49;
    //eri_ji[1*jstride+2+2*kstride] = gout49;
    eri_ij[2+2*jstride+2*kstride] = gout50;
    //eri_ji[2*jstride+2+2*kstride] = gout50;
    eri_ij[3+2*jstride+2*kstride] = gout51;
    //eri_ji[3*jstride+2+2*kstride] = gout51;
    eri_ij[4+2*jstride+2*kstride] = gout52;
    //eri_ji[4*jstride+2+2*kstride] = gout52;
    eri_ij[5+2*jstride+2*kstride] = gout53;
    //eri_ji[5*jstride+2+2*kstride] = gout53;
}

__global__
static void GINTfill_int2e_kernel2111(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double gout36 = 0;
    double gout37 = 0;
    double gout38 = 0;
    double gout39 = 0;
    double gout40 = 0;
    double gout41 = 0;
    double gout42 = 0;
    double gout43 = 0;
    double gout44 = 0;
    double gout45 = 0;
    double gout46 = 0;
    double gout47 = 0;
    double gout48 = 0;
    double gout49 = 0;
    double gout50 = 0;
    double gout51 = 0;
    double gout52 = 0;
    double gout53 = 0;
    double gout54 = 0;
    double gout55 = 0;
    double gout56 = 0;
    double gout57 = 0;
    double gout58 = 0;
    double gout59 = 0;
    double gout60 = 0;
    double gout61 = 0;
    double gout62 = 0;
    double gout63 = 0;
    double gout64 = 0;
    double gout65 = 0;
    double gout66 = 0;
    double gout67 = 0;
    double gout68 = 0;
    double gout69 = 0;
    double gout70 = 0;
    double gout71 = 0;
    double gout72 = 0;
    double gout73 = 0;
    double gout74 = 0;
    double gout75 = 0;
    double gout76 = 0;
    double gout77 = 0;
    double gout78 = 0;
    double gout79 = 0;
    double gout80 = 0;
    double gout81 = 0;
    double gout82 = 0;
    double gout83 = 0;
    double gout84 = 0;
    double gout85 = 0;
    double gout86 = 0;
    double gout87 = 0;
    double gout88 = 0;
    double gout89 = 0;
    double gout90 = 0;
    double gout91 = 0;
    double gout92 = 0;
    double gout93 = 0;
    double gout94 = 0;
    double gout95 = 0;
    double gout96 = 0;
    double gout97 = 0;
    double gout98 = 0;
    double gout99 = 0;
    double gout100 = 0;
    double gout101 = 0;
    double gout102 = 0;
    double gout103 = 0;
    double gout104 = 0;
    double gout105 = 0;
    double gout106 = 0;
    double gout107 = 0;
    double gout108 = 0;
    double gout109 = 0;
    double gout110 = 0;
    double gout111 = 0;
    double gout112 = 0;
    double gout113 = 0;
    double gout114 = 0;
    double gout115 = 0;
    double gout116 = 0;
    double gout117 = 0;
    double gout118 = 0;
    double gout119 = 0;
    double gout120 = 0;
    double gout121 = 0;
    double gout122 = 0;
    double gout123 = 0;
    double gout124 = 0;
    double gout125 = 0;
    double gout126 = 0;
    double gout127 = 0;
    double gout128 = 0;
    double gout129 = 0;
    double gout130 = 0;
    double gout131 = 0;
    double gout132 = 0;
    double gout133 = 0;
    double gout134 = 0;
    double gout135 = 0;
    double gout136 = 0;
    double gout137 = 0;
    double gout138 = 0;
    double gout139 = 0;
    double gout140 = 0;
    double gout141 = 0;
    double gout142 = 0;
    double gout143 = 0;
    double gout144 = 0;
    double gout145 = 0;
    double gout146 = 0;
    double gout147 = 0;
    double gout148 = 0;
    double gout149 = 0;
    double gout150 = 0;
    double gout151 = 0;
    double gout152 = 0;
    double gout153 = 0;
    double gout154 = 0;
    double gout155 = 0;
    double gout156 = 0;
    double gout157 = 0;
    double gout158 = 0;
    double gout159 = 0;
    double gout160 = 0;
    double gout161 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xixj = xi - bas_x[jsh];
    double yiyj = yi - bas_y[jsh];
    double zizj = zi - bas_z[jsh];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    double xkxl = xk - bas_x[lsh];
    double ykyl = yk - bas_y[lsh];
    double zkzl = zk - bas_z[lsh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double b10 = b00 + tmp4 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double b01 = b00 + tmp4 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c00x * c00x + b10;
            double g_3 = c00x + xixj;
            double g_4 = c00x * (c00x + xixj) + b10;
            double g_5 = c00x * (2 * b10 + g_2) + xixj * g_2;
            double g_6 = c0px;
            double g_7 = c0px * c00x + b00;
            double g_8 = b00 * c00x + b10 * c0px + c00x * g_7;
            double g_9 = c0px * (c00x + xixj) + b00;
            double g_10 = b00 * c00x + b10 * c0px + c00x * g_7 + xixj * g_7;
            double g_11 = 2 * b10 * g_7 + b00 * g_2 + c00x * g_8 + xixj * g_8;
            double g_12 = c0px + xkxl;
            double g_13 = c00x * (c0px + xkxl) + b00;
            double g_14 = b00 * c00x + b10 * c0px + c00x * g_7 + xkxl * g_2;
            double g_15 = xkxl * (xixj + c00x) + xixj * c0px + c0px * c00x + b00;
            double g_16 = xkxl * (xixj * c00x + c00x * c00x + b10) + xixj * g_7 + c00x * g_7 + b10 * c0px + b00 * c00x;
            double g_17 = xkxl * (xixj * g_2 + c00x * g_2 + 2 * b10 * c00x) + xixj * g_8 + c00x * g_8 + 2 * b10*g_7 + b00 * g_2;
            double g_18 = c0px * (c0px + xkxl) + b01;
            double g_19 = b00 * c0px + b01 * c00x + c0px * g_7 + xkxl * g_7;
            double g_20 = xkxl * g_8 + c00x * (c0px * g_7 + b01 * c00x + b00 * c0px) + b10 * (c0px * c0px + b01) + 2 * b00 * g_7;
            double g_21 = xkxl * (xixj * c0px + c0px * c00x + b00) + xixj * (c0px * c0px + b01) + c0px * g_7 + b01 * c00x + b00 * c0px;
            double g_22 = xkxl * (xixj * g_7 + c00x * g_7 + b10 * c0px + b00 * c00x) + xixj * (c0px * g_7 + b01 * c00x + b00 * c0px) + c00x * (c0px * g_7 + b01 * c00x + b00 * c0px) + b10 * (c0px * c0px + b01) + 2 * b00 * g_7;
            double g_23 = xkxl * (xixj * g_8 + c00x * g_8 + 2 * b10*g_7 + b00 * g_2) + xixj * (c00x * (c0px * g_7 + b01 * c00x + b00 * c0px) + b10 * (c0px * c0px + b01) + 2 * b00 * g_7) + c00x * (c00x * (c0px * g_7 + b01 * c00x + b00 * c0px) + b10 * (c0px * c0px + b01) + 2 * b00 * g_7) + 2 * b10*(c0px * g_7 + b01 * c00x + b00 * c0px) + 2 * b00 * g_8;
            double g_24 = 1;
            double g_25 = c00y;
            double g_26 = c00y * c00y + b10;
            double g_27 = c00y + yiyj;
            double g_28 = c00y * (c00y + yiyj) + b10;
            double g_29 = c00y * (2 * b10 + g_26) + yiyj * g_26;
            double g_30 = c0py;
            double g_31 = c0py * c00y + b00;
            double g_32 = b00 * c00y + b10 * c0py + c00y * g_31;
            double g_33 = c0py * (c00y + yiyj) + b00;
            double g_34 = b00 * c00y + b10 * c0py + c00y * g_31 + yiyj * g_31;
            double g_35 = 2 * b10 * g_31 + b00 * g_26 + c00y * g_32 + yiyj * g_32;
            double g_36 = c0py + ykyl;
            double g_37 = c00y * (c0py + ykyl) + b00;
            double g_38 = b00 * c00y + b10 * c0py + c00y * g_31 + ykyl * g_26;
            double g_39 = ykyl * (yiyj + c00y) + yiyj * c0py + c0py * c00y + b00;
            double g_40 = ykyl * (yiyj * c00y + c00y * c00y + b10) + yiyj * g_31 + c00y * g_31 + b10 * c0py + b00 * c00y;
            double g_41 = ykyl * (yiyj * g_26 + c00y * g_26 + 2 * b10 * c00y) + yiyj * g_32 + c00y * g_32 + 2 * b10*g_31 + b00 * g_26;
            double g_42 = c0py * (c0py + ykyl) + b01;
            double g_43 = b00 * c0py + b01 * c00y + c0py * g_31 + ykyl * g_31;
            double g_44 = ykyl * g_32 + c00y * (c0py * g_31 + b01 * c00y + b00 * c0py) + b10 * (c0py * c0py + b01) + 2 * b00 * g_31;
            double g_45 = ykyl * (yiyj * c0py + c0py * c00y + b00) + yiyj * (c0py * c0py + b01) + c0py * g_31 + b01 * c00y + b00 * c0py;
            double g_46 = ykyl * (yiyj * g_31 + c00y * g_31 + b10 * c0py + b00 * c00y) + yiyj * (c0py * g_31 + b01 * c00y + b00 * c0py) + c00y * (c0py * g_31 + b01 * c00y + b00 * c0py) + b10 * (c0py * c0py + b01) + 2 * b00 * g_31;
            double g_47 = ykyl * (yiyj * g_32 + c00y * g_32 + 2 * b10*g_31 + b00 * g_26) + yiyj * (c00y * (c0py * g_31 + b01 * c00y + b00 * c0py) + b10 * (c0py * c0py + b01) + 2 * b00 * g_31) + c00y * (c00y * (c0py * g_31 + b01 * c00y + b00 * c0py) + b10 * (c0py * c0py + b01) + 2 * b00 * g_31) + 2 * b10*(c0py * g_31 + b01 * c00y + b00 * c0py) + 2 * b00 * g_32;
            double g_48 = weight0 * fac;
            double g_49 = c00z * g_48;
            double g_50 = b10 * g_48 + c00z * g_49;
            double g_51 = g_48 * (c00z + zizj);
            double g_52 = b10 * g_48 + c00z * g_49 + zizj * g_49;
            double g_53 = 2 * b10 * g_49 + c00z * g_50 + zizj * g_50;
            double g_54 = c0pz * g_48;
            double g_55 = b00 * g_48 + c0pz * g_49;
            double g_56 = b00 * g_49 + b10 * g_54 + c00z * g_55;
            double g_57 = b00 * g_48 + c0pz * g_49 + zizj * g_54;
            double g_58 = b00 * g_49 + b10 * g_54 + c00z * g_55 + zizj * g_55;
            double g_59 = 2 * b10 * g_55 + b00 * g_50 + c00z * g_56 + zizj * g_56;
            double g_60 = g_48 * (c0pz + zkzl);
            double g_61 = b00 * g_48 + c0pz * g_49 + zkzl * g_49;
            double g_62 = b00 * g_49 + b10 * g_54 + c00z * g_55 + zkzl * g_50;
            double g_63 = zkzl * (zizj * g_48 + c00z * g_48) + zizj * g_54 + c0pz * g_49 + b00 * g_48;
            double g_64 = zkzl * (zizj * g_49 + c00z * g_49 + b10 * g_48) + zizj * g_55 + c00z * g_55 + b10 * g_54 + b00 * g_49;
            double g_65 = zkzl * (zizj * g_50 + c00z * g_50 + 2 * b10 * g_49) + zizj * g_56 + c00z * g_56 + 2 * b10*g_55 + b00 * g_50;
            double g_66 = b01 * g_48 + c0pz * g_54 + zkzl * g_54;
            double g_67 = b00 * g_54 + b01 * g_49 + c0pz * g_55 + zkzl * g_55;
            double g_68 = zkzl * g_56 + c00z * (c0pz * g_55 + b01 * g_49 + b00 * g_54) + b10 * (c0pz * g_54 + b01 * g_48) + 2 * b00 * g_55;
            double g_69 = zkzl * (zizj * g_54 + c0pz * g_49 + b00 * g_48) + zizj * (c0pz * g_54 + b01 * g_48) + c0pz * g_55 + b01 * g_49 + b00 * g_54;
            double g_70 = zkzl * (zizj * g_55 + c00z * g_55 + b10 * g_54 + b00 * g_49) + zizj * (c0pz * g_55 + b01 * g_49 + b00 * g_54) + c00z * (c0pz * g_55 + b01 * g_49 + b00 * g_54) + b10 * (c0pz * g_54 + b01 * g_48) + 2 * b00 * g_55;
            double g_71 = zkzl * (zizj * g_56 + c00z * g_56 + 2 * b10*g_55 + b00 * g_50) + zizj * (c00z * (c0pz * g_55 + b01 * g_49 + b00 * g_54) + b10 * (c0pz * g_54 + b01 * g_48) + 2 * b00 * g_55) + c00z * (c00z * (c0pz * g_55 + b01 * g_49 + b00 * g_54) + b10 * (c0pz * g_54 + b01 * g_48) + 2 * b00 * g_55) + 2 * b10*(c0pz * g_55 + b01 * g_49 + b00 * g_54) + 2 * b00 * g_56;
            gout0 += g_23 * g_24 * g_48;
            gout1 += g_22 * g_25 * g_48;
            gout2 += g_22 * g_24 * g_49;
            gout3 += g_21 * g_26 * g_48;
            gout4 += g_21 * g_25 * g_49;
            gout5 += g_21 * g_24 * g_50;
            gout6 += g_20 * g_27 * g_48;
            gout7 += g_19 * g_28 * g_48;
            gout8 += g_19 * g_27 * g_49;
            gout9 += g_18 * g_29 * g_48;
            gout10 += g_18 * g_28 * g_49;
            gout11 += g_18 * g_27 * g_50;
            gout12 += g_20 * g_24 * g_51;
            gout13 += g_19 * g_25 * g_51;
            gout14 += g_19 * g_24 * g_52;
            gout15 += g_18 * g_26 * g_51;
            gout16 += g_18 * g_25 * g_52;
            gout17 += g_18 * g_24 * g_53;
            gout18 += g_17 * g_30 * g_48;
            gout19 += g_16 * g_31 * g_48;
            gout20 += g_16 * g_30 * g_49;
            gout21 += g_15 * g_32 * g_48;
            gout22 += g_15 * g_31 * g_49;
            gout23 += g_15 * g_30 * g_50;
            gout24 += g_14 * g_33 * g_48;
            gout25 += g_13 * g_34 * g_48;
            gout26 += g_13 * g_33 * g_49;
            gout27 += g_12 * g_35 * g_48;
            gout28 += g_12 * g_34 * g_49;
            gout29 += g_12 * g_33 * g_50;
            gout30 += g_14 * g_30 * g_51;
            gout31 += g_13 * g_31 * g_51;
            gout32 += g_13 * g_30 * g_52;
            gout33 += g_12 * g_32 * g_51;
            gout34 += g_12 * g_31 * g_52;
            gout35 += g_12 * g_30 * g_53;
            gout36 += g_17 * g_24 * g_54;
            gout37 += g_16 * g_25 * g_54;
            gout38 += g_16 * g_24 * g_55;
            gout39 += g_15 * g_26 * g_54;
            gout40 += g_15 * g_25 * g_55;
            gout41 += g_15 * g_24 * g_56;
            gout42 += g_14 * g_27 * g_54;
            gout43 += g_13 * g_28 * g_54;
            gout44 += g_13 * g_27 * g_55;
            gout45 += g_12 * g_29 * g_54;
            gout46 += g_12 * g_28 * g_55;
            gout47 += g_12 * g_27 * g_56;
            gout48 += g_14 * g_24 * g_57;
            gout49 += g_13 * g_25 * g_57;
            gout50 += g_13 * g_24 * g_58;
            gout51 += g_12 * g_26 * g_57;
            gout52 += g_12 * g_25 * g_58;
            gout53 += g_12 * g_24 * g_59;
            gout54 += g_11 * g_36 * g_48;
            gout55 += g_10 * g_37 * g_48;
            gout56 += g_10 * g_36 * g_49;
            gout57 += g_9 * g_38 * g_48;
            gout58 += g_9 * g_37 * g_49;
            gout59 += g_9 * g_36 * g_50;
            gout60 += g_8 * g_39 * g_48;
            gout61 += g_7 * g_40 * g_48;
            gout62 += g_7 * g_39 * g_49;
            gout63 += g_6 * g_41 * g_48;
            gout64 += g_6 * g_40 * g_49;
            gout65 += g_6 * g_39 * g_50;
            gout66 += g_8 * g_36 * g_51;
            gout67 += g_7 * g_37 * g_51;
            gout68 += g_7 * g_36 * g_52;
            gout69 += g_6 * g_38 * g_51;
            gout70 += g_6 * g_37 * g_52;
            gout71 += g_6 * g_36 * g_53;
            gout72 += g_5 * g_42 * g_48;
            gout73 += g_4 * g_43 * g_48;
            gout74 += g_4 * g_42 * g_49;
            gout75 += g_3 * g_44 * g_48;
            gout76 += g_3 * g_43 * g_49;
            gout77 += g_3 * g_42 * g_50;
            gout78 += g_2 * g_45 * g_48;
            gout79 += g_1 * g_46 * g_48;
            gout80 += g_1 * g_45 * g_49;
            gout81 += g_0 * g_47 * g_48;
            gout82 += g_0 * g_46 * g_49;
            gout83 += g_0 * g_45 * g_50;
            gout84 += g_2 * g_42 * g_51;
            gout85 += g_1 * g_43 * g_51;
            gout86 += g_1 * g_42 * g_52;
            gout87 += g_0 * g_44 * g_51;
            gout88 += g_0 * g_43 * g_52;
            gout89 += g_0 * g_42 * g_53;
            gout90 += g_5 * g_36 * g_54;
            gout91 += g_4 * g_37 * g_54;
            gout92 += g_4 * g_36 * g_55;
            gout93 += g_3 * g_38 * g_54;
            gout94 += g_3 * g_37 * g_55;
            gout95 += g_3 * g_36 * g_56;
            gout96 += g_2 * g_39 * g_54;
            gout97 += g_1 * g_40 * g_54;
            gout98 += g_1 * g_39 * g_55;
            gout99 += g_0 * g_41 * g_54;
            gout100 += g_0 * g_40 * g_55;
            gout101 += g_0 * g_39 * g_56;
            gout102 += g_2 * g_36 * g_57;
            gout103 += g_1 * g_37 * g_57;
            gout104 += g_1 * g_36 * g_58;
            gout105 += g_0 * g_38 * g_57;
            gout106 += g_0 * g_37 * g_58;
            gout107 += g_0 * g_36 * g_59;
            gout108 += g_11 * g_24 * g_60;
            gout109 += g_10 * g_25 * g_60;
            gout110 += g_10 * g_24 * g_61;
            gout111 += g_9 * g_26 * g_60;
            gout112 += g_9 * g_25 * g_61;
            gout113 += g_9 * g_24 * g_62;
            gout114 += g_8 * g_27 * g_60;
            gout115 += g_7 * g_28 * g_60;
            gout116 += g_7 * g_27 * g_61;
            gout117 += g_6 * g_29 * g_60;
            gout118 += g_6 * g_28 * g_61;
            gout119 += g_6 * g_27 * g_62;
            gout120 += g_8 * g_24 * g_63;
            gout121 += g_7 * g_25 * g_63;
            gout122 += g_7 * g_24 * g_64;
            gout123 += g_6 * g_26 * g_63;
            gout124 += g_6 * g_25 * g_64;
            gout125 += g_6 * g_24 * g_65;
            gout126 += g_5 * g_30 * g_60;
            gout127 += g_4 * g_31 * g_60;
            gout128 += g_4 * g_30 * g_61;
            gout129 += g_3 * g_32 * g_60;
            gout130 += g_3 * g_31 * g_61;
            gout131 += g_3 * g_30 * g_62;
            gout132 += g_2 * g_33 * g_60;
            gout133 += g_1 * g_34 * g_60;
            gout134 += g_1 * g_33 * g_61;
            gout135 += g_0 * g_35 * g_60;
            gout136 += g_0 * g_34 * g_61;
            gout137 += g_0 * g_33 * g_62;
            gout138 += g_2 * g_30 * g_63;
            gout139 += g_1 * g_31 * g_63;
            gout140 += g_1 * g_30 * g_64;
            gout141 += g_0 * g_32 * g_63;
            gout142 += g_0 * g_31 * g_64;
            gout143 += g_0 * g_30 * g_65;
            gout144 += g_5 * g_24 * g_66;
            gout145 += g_4 * g_25 * g_66;
            gout146 += g_4 * g_24 * g_67;
            gout147 += g_3 * g_26 * g_66;
            gout148 += g_3 * g_25 * g_67;
            gout149 += g_3 * g_24 * g_68;
            gout150 += g_2 * g_27 * g_66;
            gout151 += g_1 * g_28 * g_66;
            gout152 += g_1 * g_27 * g_67;
            gout153 += g_0 * g_29 * g_66;
            gout154 += g_0 * g_28 * g_67;
            gout155 += g_0 * g_27 * g_68;
            gout156 += g_2 * g_24 * g_69;
            gout157 += g_1 * g_25 * g_69;
            gout158 += g_1 * g_24 * g_70;
            gout159 += g_0 * g_26 * g_69;
            gout160 += g_0 * g_25 * g_70;
            gout161 += g_0 * g_24 * g_71;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[3] = gout3;
    //eri_ji[3*jstride] = gout3;
    eri_ij[4] = gout4;
    //eri_ji[4*jstride] = gout4;
    eri_ij[5] = gout5;
    //eri_ji[5*jstride] = gout5;
    eri_ij[1*jstride] = gout6;
    //eri_ji[1] = gout6;
    eri_ij[1+1*jstride] = gout7;
    //eri_ji[1*jstride+1] = gout7;
    eri_ij[2+1*jstride] = gout8;
    //eri_ji[2*jstride+1] = gout8;
    eri_ij[3+1*jstride] = gout9;
    //eri_ji[3*jstride+1] = gout9;
    eri_ij[4+1*jstride] = gout10;
    //eri_ji[4*jstride+1] = gout10;
    eri_ij[5+1*jstride] = gout11;
    //eri_ji[5*jstride+1] = gout11;
    eri_ij[2*jstride] = gout12;
    //eri_ji[2] = gout12;
    eri_ij[1+2*jstride] = gout13;
    //eri_ji[1*jstride+2] = gout13;
    eri_ij[2+2*jstride] = gout14;
    //eri_ji[2*jstride+2] = gout14;
    eri_ij[3+2*jstride] = gout15;
    //eri_ji[3*jstride+2] = gout15;
    eri_ij[4+2*jstride] = gout16;
    //eri_ji[4*jstride+2] = gout16;
    eri_ij[5+2*jstride] = gout17;
    //eri_ji[5*jstride+2] = gout17;
    eri_ij[1*kstride] = gout18;
    //eri_ji[1*kstride] = gout18;
    eri_ij[1+1*kstride] = gout19;
    //eri_ji[1*jstride+1*kstride] = gout19;
    eri_ij[2+1*kstride] = gout20;
    //eri_ji[2*jstride+1*kstride] = gout20;
    eri_ij[3+1*kstride] = gout21;
    //eri_ji[3*jstride+1*kstride] = gout21;
    eri_ij[4+1*kstride] = gout22;
    //eri_ji[4*jstride+1*kstride] = gout22;
    eri_ij[5+1*kstride] = gout23;
    //eri_ji[5*jstride+1*kstride] = gout23;
    eri_ij[1*jstride+1*kstride] = gout24;
    //eri_ji[1+1*kstride] = gout24;
    eri_ij[1+1*jstride+1*kstride] = gout25;
    //eri_ji[1*jstride+1+1*kstride] = gout25;
    eri_ij[2+1*jstride+1*kstride] = gout26;
    //eri_ji[2*jstride+1+1*kstride] = gout26;
    eri_ij[3+1*jstride+1*kstride] = gout27;
    //eri_ji[3*jstride+1+1*kstride] = gout27;
    eri_ij[4+1*jstride+1*kstride] = gout28;
    //eri_ji[4*jstride+1+1*kstride] = gout28;
    eri_ij[5+1*jstride+1*kstride] = gout29;
    //eri_ji[5*jstride+1+1*kstride] = gout29;
    eri_ij[2*jstride+1*kstride] = gout30;
    //eri_ji[2+1*kstride] = gout30;
    eri_ij[1+2*jstride+1*kstride] = gout31;
    //eri_ji[1*jstride+2+1*kstride] = gout31;
    eri_ij[2+2*jstride+1*kstride] = gout32;
    //eri_ji[2*jstride+2+1*kstride] = gout32;
    eri_ij[3+2*jstride+1*kstride] = gout33;
    //eri_ji[3*jstride+2+1*kstride] = gout33;
    eri_ij[4+2*jstride+1*kstride] = gout34;
    //eri_ji[4*jstride+2+1*kstride] = gout34;
    eri_ij[5+2*jstride+1*kstride] = gout35;
    //eri_ji[5*jstride+2+1*kstride] = gout35;
    eri_ij[2*kstride] = gout36;
    //eri_ji[2*kstride] = gout36;
    eri_ij[1+2*kstride] = gout37;
    //eri_ji[1*jstride+2*kstride] = gout37;
    eri_ij[2+2*kstride] = gout38;
    //eri_ji[2*jstride+2*kstride] = gout38;
    eri_ij[3+2*kstride] = gout39;
    //eri_ji[3*jstride+2*kstride] = gout39;
    eri_ij[4+2*kstride] = gout40;
    //eri_ji[4*jstride+2*kstride] = gout40;
    eri_ij[5+2*kstride] = gout41;
    //eri_ji[5*jstride+2*kstride] = gout41;
    eri_ij[1*jstride+2*kstride] = gout42;
    //eri_ji[1+2*kstride] = gout42;
    eri_ij[1+1*jstride+2*kstride] = gout43;
    //eri_ji[1*jstride+1+2*kstride] = gout43;
    eri_ij[2+1*jstride+2*kstride] = gout44;
    //eri_ji[2*jstride+1+2*kstride] = gout44;
    eri_ij[3+1*jstride+2*kstride] = gout45;
    //eri_ji[3*jstride+1+2*kstride] = gout45;
    eri_ij[4+1*jstride+2*kstride] = gout46;
    //eri_ji[4*jstride+1+2*kstride] = gout46;
    eri_ij[5+1*jstride+2*kstride] = gout47;
    //eri_ji[5*jstride+1+2*kstride] = gout47;
    eri_ij[2*jstride+2*kstride] = gout48;
    //eri_ji[2+2*kstride] = gout48;
    eri_ij[1+2*jstride+2*kstride] = gout49;
    //eri_ji[1*jstride+2+2*kstride] = gout49;
    eri_ij[2+2*jstride+2*kstride] = gout50;
    //eri_ji[2*jstride+2+2*kstride] = gout50;
    eri_ij[3+2*jstride+2*kstride] = gout51;
    //eri_ji[3*jstride+2+2*kstride] = gout51;
    eri_ij[4+2*jstride+2*kstride] = gout52;
    //eri_ji[4*jstride+2+2*kstride] = gout52;
    eri_ij[5+2*jstride+2*kstride] = gout53;
    //eri_ji[5*jstride+2+2*kstride] = gout53;
    eri_ij[1*lstride] = gout54;
    //eri_ji[1*lstride] = gout54;
    eri_ij[1+1*lstride] = gout55;
    //eri_ji[1*jstride+1*lstride] = gout55;
    eri_ij[2+1*lstride] = gout56;
    //eri_ji[2*jstride+1*lstride] = gout56;
    eri_ij[3+1*lstride] = gout57;
    //eri_ji[3*jstride+1*lstride] = gout57;
    eri_ij[4+1*lstride] = gout58;
    //eri_ji[4*jstride+1*lstride] = gout58;
    eri_ij[5+1*lstride] = gout59;
    //eri_ji[5*jstride+1*lstride] = gout59;
    eri_ij[1*jstride+1*lstride] = gout60;
    //eri_ji[1+1*lstride] = gout60;
    eri_ij[1+1*jstride+1*lstride] = gout61;
    //eri_ji[1*jstride+1+1*lstride] = gout61;
    eri_ij[2+1*jstride+1*lstride] = gout62;
    //eri_ji[2*jstride+1+1*lstride] = gout62;
    eri_ij[3+1*jstride+1*lstride] = gout63;
    //eri_ji[3*jstride+1+1*lstride] = gout63;
    eri_ij[4+1*jstride+1*lstride] = gout64;
    //eri_ji[4*jstride+1+1*lstride] = gout64;
    eri_ij[5+1*jstride+1*lstride] = gout65;
    //eri_ji[5*jstride+1+1*lstride] = gout65;
    eri_ij[2*jstride+1*lstride] = gout66;
    //eri_ji[2+1*lstride] = gout66;
    eri_ij[1+2*jstride+1*lstride] = gout67;
    //eri_ji[1*jstride+2+1*lstride] = gout67;
    eri_ij[2+2*jstride+1*lstride] = gout68;
    //eri_ji[2*jstride+2+1*lstride] = gout68;
    eri_ij[3+2*jstride+1*lstride] = gout69;
    //eri_ji[3*jstride+2+1*lstride] = gout69;
    eri_ij[4+2*jstride+1*lstride] = gout70;
    //eri_ji[4*jstride+2+1*lstride] = gout70;
    eri_ij[5+2*jstride+1*lstride] = gout71;
    //eri_ji[5*jstride+2+1*lstride] = gout71;
    eri_ij[1*kstride+1*lstride] = gout72;
    //eri_ji[1*kstride+1*lstride] = gout72;
    eri_ij[1+1*kstride+1*lstride] = gout73;
    //eri_ji[1*jstride+1*kstride+1*lstride] = gout73;
    eri_ij[2+1*kstride+1*lstride] = gout74;
    //eri_ji[2*jstride+1*kstride+1*lstride] = gout74;
    eri_ij[3+1*kstride+1*lstride] = gout75;
    //eri_ji[3*jstride+1*kstride+1*lstride] = gout75;
    eri_ij[4+1*kstride+1*lstride] = gout76;
    //eri_ji[4*jstride+1*kstride+1*lstride] = gout76;
    eri_ij[5+1*kstride+1*lstride] = gout77;
    //eri_ji[5*jstride+1*kstride+1*lstride] = gout77;
    eri_ij[1*jstride+1*kstride+1*lstride] = gout78;
    //eri_ji[1+1*kstride+1*lstride] = gout78;
    eri_ij[1+1*jstride+1*kstride+1*lstride] = gout79;
    //eri_ji[1*jstride+1+1*kstride+1*lstride] = gout79;
    eri_ij[2+1*jstride+1*kstride+1*lstride] = gout80;
    //eri_ji[2*jstride+1+1*kstride+1*lstride] = gout80;
    eri_ij[3+1*jstride+1*kstride+1*lstride] = gout81;
    //eri_ji[3*jstride+1+1*kstride+1*lstride] = gout81;
    eri_ij[4+1*jstride+1*kstride+1*lstride] = gout82;
    //eri_ji[4*jstride+1+1*kstride+1*lstride] = gout82;
    eri_ij[5+1*jstride+1*kstride+1*lstride] = gout83;
    //eri_ji[5*jstride+1+1*kstride+1*lstride] = gout83;
    eri_ij[2*jstride+1*kstride+1*lstride] = gout84;
    //eri_ji[2+1*kstride+1*lstride] = gout84;
    eri_ij[1+2*jstride+1*kstride+1*lstride] = gout85;
    //eri_ji[1*jstride+2+1*kstride+1*lstride] = gout85;
    eri_ij[2+2*jstride+1*kstride+1*lstride] = gout86;
    //eri_ji[2*jstride+2+1*kstride+1*lstride] = gout86;
    eri_ij[3+2*jstride+1*kstride+1*lstride] = gout87;
    //eri_ji[3*jstride+2+1*kstride+1*lstride] = gout87;
    eri_ij[4+2*jstride+1*kstride+1*lstride] = gout88;
    //eri_ji[4*jstride+2+1*kstride+1*lstride] = gout88;
    eri_ij[5+2*jstride+1*kstride+1*lstride] = gout89;
    //eri_ji[5*jstride+2+1*kstride+1*lstride] = gout89;
    eri_ij[2*kstride+1*lstride] = gout90;
    //eri_ji[2*kstride+1*lstride] = gout90;
    eri_ij[1+2*kstride+1*lstride] = gout91;
    //eri_ji[1*jstride+2*kstride+1*lstride] = gout91;
    eri_ij[2+2*kstride+1*lstride] = gout92;
    //eri_ji[2*jstride+2*kstride+1*lstride] = gout92;
    eri_ij[3+2*kstride+1*lstride] = gout93;
    //eri_ji[3*jstride+2*kstride+1*lstride] = gout93;
    eri_ij[4+2*kstride+1*lstride] = gout94;
    //eri_ji[4*jstride+2*kstride+1*lstride] = gout94;
    eri_ij[5+2*kstride+1*lstride] = gout95;
    //eri_ji[5*jstride+2*kstride+1*lstride] = gout95;
    eri_ij[1*jstride+2*kstride+1*lstride] = gout96;
    //eri_ji[1+2*kstride+1*lstride] = gout96;
    eri_ij[1+1*jstride+2*kstride+1*lstride] = gout97;
    //eri_ji[1*jstride+1+2*kstride+1*lstride] = gout97;
    eri_ij[2+1*jstride+2*kstride+1*lstride] = gout98;
    //eri_ji[2*jstride+1+2*kstride+1*lstride] = gout98;
    eri_ij[3+1*jstride+2*kstride+1*lstride] = gout99;
    //eri_ji[3*jstride+1+2*kstride+1*lstride] = gout99;
    eri_ij[4+1*jstride+2*kstride+1*lstride] = gout100;
    //eri_ji[4*jstride+1+2*kstride+1*lstride] = gout100;
    eri_ij[5+1*jstride+2*kstride+1*lstride] = gout101;
    //eri_ji[5*jstride+1+2*kstride+1*lstride] = gout101;
    eri_ij[2*jstride+2*kstride+1*lstride] = gout102;
    //eri_ji[2+2*kstride+1*lstride] = gout102;
    eri_ij[1+2*jstride+2*kstride+1*lstride] = gout103;
    //eri_ji[1*jstride+2+2*kstride+1*lstride] = gout103;
    eri_ij[2+2*jstride+2*kstride+1*lstride] = gout104;
    //eri_ji[2*jstride+2+2*kstride+1*lstride] = gout104;
    eri_ij[3+2*jstride+2*kstride+1*lstride] = gout105;
    //eri_ji[3*jstride+2+2*kstride+1*lstride] = gout105;
    eri_ij[4+2*jstride+2*kstride+1*lstride] = gout106;
    //eri_ji[4*jstride+2+2*kstride+1*lstride] = gout106;
    eri_ij[5+2*jstride+2*kstride+1*lstride] = gout107;
    //eri_ji[5*jstride+2+2*kstride+1*lstride] = gout107;
    eri_ij[2*lstride] = gout108;
    //eri_ji[2*lstride] = gout108;
    eri_ij[1+2*lstride] = gout109;
    //eri_ji[1*jstride+2*lstride] = gout109;
    eri_ij[2+2*lstride] = gout110;
    //eri_ji[2*jstride+2*lstride] = gout110;
    eri_ij[3+2*lstride] = gout111;
    //eri_ji[3*jstride+2*lstride] = gout111;
    eri_ij[4+2*lstride] = gout112;
    //eri_ji[4*jstride+2*lstride] = gout112;
    eri_ij[5+2*lstride] = gout113;
    //eri_ji[5*jstride+2*lstride] = gout113;
    eri_ij[1*jstride+2*lstride] = gout114;
    //eri_ji[1+2*lstride] = gout114;
    eri_ij[1+1*jstride+2*lstride] = gout115;
    //eri_ji[1*jstride+1+2*lstride] = gout115;
    eri_ij[2+1*jstride+2*lstride] = gout116;
    //eri_ji[2*jstride+1+2*lstride] = gout116;
    eri_ij[3+1*jstride+2*lstride] = gout117;
    //eri_ji[3*jstride+1+2*lstride] = gout117;
    eri_ij[4+1*jstride+2*lstride] = gout118;
    //eri_ji[4*jstride+1+2*lstride] = gout118;
    eri_ij[5+1*jstride+2*lstride] = gout119;
    //eri_ji[5*jstride+1+2*lstride] = gout119;
    eri_ij[2*jstride+2*lstride] = gout120;
    //eri_ji[2+2*lstride] = gout120;
    eri_ij[1+2*jstride+2*lstride] = gout121;
    //eri_ji[1*jstride+2+2*lstride] = gout121;
    eri_ij[2+2*jstride+2*lstride] = gout122;
    //eri_ji[2*jstride+2+2*lstride] = gout122;
    eri_ij[3+2*jstride+2*lstride] = gout123;
    //eri_ji[3*jstride+2+2*lstride] = gout123;
    eri_ij[4+2*jstride+2*lstride] = gout124;
    //eri_ji[4*jstride+2+2*lstride] = gout124;
    eri_ij[5+2*jstride+2*lstride] = gout125;
    //eri_ji[5*jstride+2+2*lstride] = gout125;
    eri_ij[1*kstride+2*lstride] = gout126;
    //eri_ji[1*kstride+2*lstride] = gout126;
    eri_ij[1+1*kstride+2*lstride] = gout127;
    //eri_ji[1*jstride+1*kstride+2*lstride] = gout127;
    eri_ij[2+1*kstride+2*lstride] = gout128;
    //eri_ji[2*jstride+1*kstride+2*lstride] = gout128;
    eri_ij[3+1*kstride+2*lstride] = gout129;
    //eri_ji[3*jstride+1*kstride+2*lstride] = gout129;
    eri_ij[4+1*kstride+2*lstride] = gout130;
    //eri_ji[4*jstride+1*kstride+2*lstride] = gout130;
    eri_ij[5+1*kstride+2*lstride] = gout131;
    //eri_ji[5*jstride+1*kstride+2*lstride] = gout131;
    eri_ij[1*jstride+1*kstride+2*lstride] = gout132;
    //eri_ji[1+1*kstride+2*lstride] = gout132;
    eri_ij[1+1*jstride+1*kstride+2*lstride] = gout133;
    //eri_ji[1*jstride+1+1*kstride+2*lstride] = gout133;
    eri_ij[2+1*jstride+1*kstride+2*lstride] = gout134;
    //eri_ji[2*jstride+1+1*kstride+2*lstride] = gout134;
    eri_ij[3+1*jstride+1*kstride+2*lstride] = gout135;
    //eri_ji[3*jstride+1+1*kstride+2*lstride] = gout135;
    eri_ij[4+1*jstride+1*kstride+2*lstride] = gout136;
    //eri_ji[4*jstride+1+1*kstride+2*lstride] = gout136;
    eri_ij[5+1*jstride+1*kstride+2*lstride] = gout137;
    //eri_ji[5*jstride+1+1*kstride+2*lstride] = gout137;
    eri_ij[2*jstride+1*kstride+2*lstride] = gout138;
    //eri_ji[2+1*kstride+2*lstride] = gout138;
    eri_ij[1+2*jstride+1*kstride+2*lstride] = gout139;
    //eri_ji[1*jstride+2+1*kstride+2*lstride] = gout139;
    eri_ij[2+2*jstride+1*kstride+2*lstride] = gout140;
    //eri_ji[2*jstride+2+1*kstride+2*lstride] = gout140;
    eri_ij[3+2*jstride+1*kstride+2*lstride] = gout141;
    //eri_ji[3*jstride+2+1*kstride+2*lstride] = gout141;
    eri_ij[4+2*jstride+1*kstride+2*lstride] = gout142;
    //eri_ji[4*jstride+2+1*kstride+2*lstride] = gout142;
    eri_ij[5+2*jstride+1*kstride+2*lstride] = gout143;
    //eri_ji[5*jstride+2+1*kstride+2*lstride] = gout143;
    eri_ij[2*kstride+2*lstride] = gout144;
    //eri_ji[2*kstride+2*lstride] = gout144;
    eri_ij[1+2*kstride+2*lstride] = gout145;
    //eri_ji[1*jstride+2*kstride+2*lstride] = gout145;
    eri_ij[2+2*kstride+2*lstride] = gout146;
    //eri_ji[2*jstride+2*kstride+2*lstride] = gout146;
    eri_ij[3+2*kstride+2*lstride] = gout147;
    //eri_ji[3*jstride+2*kstride+2*lstride] = gout147;
    eri_ij[4+2*kstride+2*lstride] = gout148;
    //eri_ji[4*jstride+2*kstride+2*lstride] = gout148;
    eri_ij[5+2*kstride+2*lstride] = gout149;
    //eri_ji[5*jstride+2*kstride+2*lstride] = gout149;
    eri_ij[1*jstride+2*kstride+2*lstride] = gout150;
    //eri_ji[1+2*kstride+2*lstride] = gout150;
    eri_ij[1+1*jstride+2*kstride+2*lstride] = gout151;
    //eri_ji[1*jstride+1+2*kstride+2*lstride] = gout151;
    eri_ij[2+1*jstride+2*kstride+2*lstride] = gout152;
    //eri_ji[2*jstride+1+2*kstride+2*lstride] = gout152;
    eri_ij[3+1*jstride+2*kstride+2*lstride] = gout153;
    //eri_ji[3*jstride+1+2*kstride+2*lstride] = gout153;
    eri_ij[4+1*jstride+2*kstride+2*lstride] = gout154;
    //eri_ji[4*jstride+1+2*kstride+2*lstride] = gout154;
    eri_ij[5+1*jstride+2*kstride+2*lstride] = gout155;
    //eri_ji[5*jstride+1+2*kstride+2*lstride] = gout155;
    eri_ij[2*jstride+2*kstride+2*lstride] = gout156;
    //eri_ji[2+2*kstride+2*lstride] = gout156;
    eri_ij[1+2*jstride+2*kstride+2*lstride] = gout157;
    //eri_ji[1*jstride+2+2*kstride+2*lstride] = gout157;
    eri_ij[2+2*jstride+2*kstride+2*lstride] = gout158;
    //eri_ji[2*jstride+2+2*kstride+2*lstride] = gout158;
    eri_ij[3+2*jstride+2*kstride+2*lstride] = gout159;
    //eri_ji[3*jstride+2+2*kstride+2*lstride] = gout159;
    eri_ij[4+2*jstride+2*kstride+2*lstride] = gout160;
    //eri_ji[4*jstride+2+2*kstride+2*lstride] = gout160;
    eri_ij[5+2*jstride+2*kstride+2*lstride] = gout161;
    //eri_ji[5*jstride+2+2*kstride+2*lstride] = gout161;
}

__global__
static void GINTfill_int2e_kernel2120(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double gout36 = 0;
    double gout37 = 0;
    double gout38 = 0;
    double gout39 = 0;
    double gout40 = 0;
    double gout41 = 0;
    double gout42 = 0;
    double gout43 = 0;
    double gout44 = 0;
    double gout45 = 0;
    double gout46 = 0;
    double gout47 = 0;
    double gout48 = 0;
    double gout49 = 0;
    double gout50 = 0;
    double gout51 = 0;
    double gout52 = 0;
    double gout53 = 0;
    double gout54 = 0;
    double gout55 = 0;
    double gout56 = 0;
    double gout57 = 0;
    double gout58 = 0;
    double gout59 = 0;
    double gout60 = 0;
    double gout61 = 0;
    double gout62 = 0;
    double gout63 = 0;
    double gout64 = 0;
    double gout65 = 0;
    double gout66 = 0;
    double gout67 = 0;
    double gout68 = 0;
    double gout69 = 0;
    double gout70 = 0;
    double gout71 = 0;
    double gout72 = 0;
    double gout73 = 0;
    double gout74 = 0;
    double gout75 = 0;
    double gout76 = 0;
    double gout77 = 0;
    double gout78 = 0;
    double gout79 = 0;
    double gout80 = 0;
    double gout81 = 0;
    double gout82 = 0;
    double gout83 = 0;
    double gout84 = 0;
    double gout85 = 0;
    double gout86 = 0;
    double gout87 = 0;
    double gout88 = 0;
    double gout89 = 0;
    double gout90 = 0;
    double gout91 = 0;
    double gout92 = 0;
    double gout93 = 0;
    double gout94 = 0;
    double gout95 = 0;
    double gout96 = 0;
    double gout97 = 0;
    double gout98 = 0;
    double gout99 = 0;
    double gout100 = 0;
    double gout101 = 0;
    double gout102 = 0;
    double gout103 = 0;
    double gout104 = 0;
    double gout105 = 0;
    double gout106 = 0;
    double gout107 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xixj = xi - bas_x[jsh];
    double yiyj = yi - bas_y[jsh];
    double zizj = zi - bas_z[jsh];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double b10 = b00 + tmp4 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double b01 = b00 + tmp4 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c00x * c00x + b10;
            double g_3 = c00x + xixj;
            double g_4 = c00x * (c00x + xixj) + b10;
            double g_5 = c00x * (2 * b10 + g_2) + xixj * g_2;
            double g_6 = c0px;
            double g_7 = c0px * c00x + b00;
            double g_8 = b00 * c00x + b10 * c0px + c00x * g_7;
            double g_9 = c0px * (c00x + xixj) + b00;
            double g_10 = b00 * c00x + b10 * c0px + c00x * g_7 + xixj * g_7;
            double g_11 = 2 * b10 * g_7 + b00 * g_2 + c00x * g_8 + xixj * g_8;
            double g_12 = c0px * c0px + b01;
            double g_13 = b00 * c0px + b01 * c00x + c0px * g_7;
            double g_14 = 2 * b00 * g_7 + b10 * g_12 + c00x * g_13;
            double g_15 = b00 * c0px + b01 * c00x + c0px * g_7 + xixj * g_12;
            double g_16 = 2 * b00 * g_7 + b10 * g_12 + c00x * g_13 + xixj * g_13;
            double g_17 = 2 * (b00 * g_8 + b10 * g_13) + c00x * g_14 + xixj * g_14;
            double g_18 = 1;
            double g_19 = c00y;
            double g_20 = c00y * c00y + b10;
            double g_21 = c00y + yiyj;
            double g_22 = c00y * (c00y + yiyj) + b10;
            double g_23 = c00y * (2 * b10 + g_20) + yiyj * g_20;
            double g_24 = c0py;
            double g_25 = c0py * c00y + b00;
            double g_26 = b00 * c00y + b10 * c0py + c00y * g_25;
            double g_27 = c0py * (c00y + yiyj) + b00;
            double g_28 = b00 * c00y + b10 * c0py + c00y * g_25 + yiyj * g_25;
            double g_29 = 2 * b10 * g_25 + b00 * g_20 + c00y * g_26 + yiyj * g_26;
            double g_30 = c0py * c0py + b01;
            double g_31 = b00 * c0py + b01 * c00y + c0py * g_25;
            double g_32 = 2 * b00 * g_25 + b10 * g_30 + c00y * g_31;
            double g_33 = b00 * c0py + b01 * c00y + c0py * g_25 + yiyj * g_30;
            double g_34 = 2 * b00 * g_25 + b10 * g_30 + c00y * g_31 + yiyj * g_31;
            double g_35 = 2 * (b00 * g_26 + b10 * g_31) + c00y * g_32 + yiyj * g_32;
            double g_36 = weight0 * fac;
            double g_37 = c00z * g_36;
            double g_38 = b10 * g_36 + c00z * g_37;
            double g_39 = g_36 * (c00z + zizj);
            double g_40 = b10 * g_36 + c00z * g_37 + zizj * g_37;
            double g_41 = 2 * b10 * g_37 + c00z * g_38 + zizj * g_38;
            double g_42 = c0pz * g_36;
            double g_43 = b00 * g_36 + c0pz * g_37;
            double g_44 = b00 * g_37 + b10 * g_42 + c00z * g_43;
            double g_45 = b00 * g_36 + c0pz * g_37 + zizj * g_42;
            double g_46 = b00 * g_37 + b10 * g_42 + c00z * g_43 + zizj * g_43;
            double g_47 = 2 * b10 * g_43 + b00 * g_38 + c00z * g_44 + zizj * g_44;
            double g_48 = b01 * g_36 + c0pz * g_42;
            double g_49 = b00 * g_42 + b01 * g_37 + c0pz * g_43;
            double g_50 = 2 * b00 * g_43 + b10 * g_48 + c00z * g_49;
            double g_51 = b00 * g_42 + b01 * g_37 + c0pz * g_43 + zizj * g_48;
            double g_52 = 2 * b00 * g_43 + b10 * g_48 + c00z * g_49 + zizj * g_49;
            double g_53 = 2 * (b00 * g_44 + b10 * g_49) + c00z * g_50 + zizj * g_50;
            gout0 += g_17 * g_18 * g_36;
            gout1 += g_16 * g_19 * g_36;
            gout2 += g_16 * g_18 * g_37;
            gout3 += g_15 * g_20 * g_36;
            gout4 += g_15 * g_19 * g_37;
            gout5 += g_15 * g_18 * g_38;
            gout6 += g_14 * g_21 * g_36;
            gout7 += g_13 * g_22 * g_36;
            gout8 += g_13 * g_21 * g_37;
            gout9 += g_12 * g_23 * g_36;
            gout10 += g_12 * g_22 * g_37;
            gout11 += g_12 * g_21 * g_38;
            gout12 += g_14 * g_18 * g_39;
            gout13 += g_13 * g_19 * g_39;
            gout14 += g_13 * g_18 * g_40;
            gout15 += g_12 * g_20 * g_39;
            gout16 += g_12 * g_19 * g_40;
            gout17 += g_12 * g_18 * g_41;
            gout18 += g_11 * g_24 * g_36;
            gout19 += g_10 * g_25 * g_36;
            gout20 += g_10 * g_24 * g_37;
            gout21 += g_9 * g_26 * g_36;
            gout22 += g_9 * g_25 * g_37;
            gout23 += g_9 * g_24 * g_38;
            gout24 += g_8 * g_27 * g_36;
            gout25 += g_7 * g_28 * g_36;
            gout26 += g_7 * g_27 * g_37;
            gout27 += g_6 * g_29 * g_36;
            gout28 += g_6 * g_28 * g_37;
            gout29 += g_6 * g_27 * g_38;
            gout30 += g_8 * g_24 * g_39;
            gout31 += g_7 * g_25 * g_39;
            gout32 += g_7 * g_24 * g_40;
            gout33 += g_6 * g_26 * g_39;
            gout34 += g_6 * g_25 * g_40;
            gout35 += g_6 * g_24 * g_41;
            gout36 += g_11 * g_18 * g_42;
            gout37 += g_10 * g_19 * g_42;
            gout38 += g_10 * g_18 * g_43;
            gout39 += g_9 * g_20 * g_42;
            gout40 += g_9 * g_19 * g_43;
            gout41 += g_9 * g_18 * g_44;
            gout42 += g_8 * g_21 * g_42;
            gout43 += g_7 * g_22 * g_42;
            gout44 += g_7 * g_21 * g_43;
            gout45 += g_6 * g_23 * g_42;
            gout46 += g_6 * g_22 * g_43;
            gout47 += g_6 * g_21 * g_44;
            gout48 += g_8 * g_18 * g_45;
            gout49 += g_7 * g_19 * g_45;
            gout50 += g_7 * g_18 * g_46;
            gout51 += g_6 * g_20 * g_45;
            gout52 += g_6 * g_19 * g_46;
            gout53 += g_6 * g_18 * g_47;
            gout54 += g_5 * g_30 * g_36;
            gout55 += g_4 * g_31 * g_36;
            gout56 += g_4 * g_30 * g_37;
            gout57 += g_3 * g_32 * g_36;
            gout58 += g_3 * g_31 * g_37;
            gout59 += g_3 * g_30 * g_38;
            gout60 += g_2 * g_33 * g_36;
            gout61 += g_1 * g_34 * g_36;
            gout62 += g_1 * g_33 * g_37;
            gout63 += g_0 * g_35 * g_36;
            gout64 += g_0 * g_34 * g_37;
            gout65 += g_0 * g_33 * g_38;
            gout66 += g_2 * g_30 * g_39;
            gout67 += g_1 * g_31 * g_39;
            gout68 += g_1 * g_30 * g_40;
            gout69 += g_0 * g_32 * g_39;
            gout70 += g_0 * g_31 * g_40;
            gout71 += g_0 * g_30 * g_41;
            gout72 += g_5 * g_24 * g_42;
            gout73 += g_4 * g_25 * g_42;
            gout74 += g_4 * g_24 * g_43;
            gout75 += g_3 * g_26 * g_42;
            gout76 += g_3 * g_25 * g_43;
            gout77 += g_3 * g_24 * g_44;
            gout78 += g_2 * g_27 * g_42;
            gout79 += g_1 * g_28 * g_42;
            gout80 += g_1 * g_27 * g_43;
            gout81 += g_0 * g_29 * g_42;
            gout82 += g_0 * g_28 * g_43;
            gout83 += g_0 * g_27 * g_44;
            gout84 += g_2 * g_24 * g_45;
            gout85 += g_1 * g_25 * g_45;
            gout86 += g_1 * g_24 * g_46;
            gout87 += g_0 * g_26 * g_45;
            gout88 += g_0 * g_25 * g_46;
            gout89 += g_0 * g_24 * g_47;
            gout90 += g_5 * g_18 * g_48;
            gout91 += g_4 * g_19 * g_48;
            gout92 += g_4 * g_18 * g_49;
            gout93 += g_3 * g_20 * g_48;
            gout94 += g_3 * g_19 * g_49;
            gout95 += g_3 * g_18 * g_50;
            gout96 += g_2 * g_21 * g_48;
            gout97 += g_1 * g_22 * g_48;
            gout98 += g_1 * g_21 * g_49;
            gout99 += g_0 * g_23 * g_48;
            gout100 += g_0 * g_22 * g_49;
            gout101 += g_0 * g_21 * g_50;
            gout102 += g_2 * g_18 * g_51;
            gout103 += g_1 * g_19 * g_51;
            gout104 += g_1 * g_18 * g_52;
            gout105 += g_0 * g_20 * g_51;
            gout106 += g_0 * g_19 * g_52;
            gout107 += g_0 * g_18 * g_53;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[3] = gout3;
    //eri_ji[3*jstride] = gout3;
    eri_ij[4] = gout4;
    //eri_ji[4*jstride] = gout4;
    eri_ij[5] = gout5;
    //eri_ji[5*jstride] = gout5;
    eri_ij[1*jstride] = gout6;
    //eri_ji[1] = gout6;
    eri_ij[1+1*jstride] = gout7;
    //eri_ji[1*jstride+1] = gout7;
    eri_ij[2+1*jstride] = gout8;
    //eri_ji[2*jstride+1] = gout8;
    eri_ij[3+1*jstride] = gout9;
    //eri_ji[3*jstride+1] = gout9;
    eri_ij[4+1*jstride] = gout10;
    //eri_ji[4*jstride+1] = gout10;
    eri_ij[5+1*jstride] = gout11;
    //eri_ji[5*jstride+1] = gout11;
    eri_ij[2*jstride] = gout12;
    //eri_ji[2] = gout12;
    eri_ij[1+2*jstride] = gout13;
    //eri_ji[1*jstride+2] = gout13;
    eri_ij[2+2*jstride] = gout14;
    //eri_ji[2*jstride+2] = gout14;
    eri_ij[3+2*jstride] = gout15;
    //eri_ji[3*jstride+2] = gout15;
    eri_ij[4+2*jstride] = gout16;
    //eri_ji[4*jstride+2] = gout16;
    eri_ij[5+2*jstride] = gout17;
    //eri_ji[5*jstride+2] = gout17;
    eri_ij[1*kstride] = gout18;
    //eri_ji[1*kstride] = gout18;
    eri_ij[1+1*kstride] = gout19;
    //eri_ji[1*jstride+1*kstride] = gout19;
    eri_ij[2+1*kstride] = gout20;
    //eri_ji[2*jstride+1*kstride] = gout20;
    eri_ij[3+1*kstride] = gout21;
    //eri_ji[3*jstride+1*kstride] = gout21;
    eri_ij[4+1*kstride] = gout22;
    //eri_ji[4*jstride+1*kstride] = gout22;
    eri_ij[5+1*kstride] = gout23;
    //eri_ji[5*jstride+1*kstride] = gout23;
    eri_ij[1*jstride+1*kstride] = gout24;
    //eri_ji[1+1*kstride] = gout24;
    eri_ij[1+1*jstride+1*kstride] = gout25;
    //eri_ji[1*jstride+1+1*kstride] = gout25;
    eri_ij[2+1*jstride+1*kstride] = gout26;
    //eri_ji[2*jstride+1+1*kstride] = gout26;
    eri_ij[3+1*jstride+1*kstride] = gout27;
    //eri_ji[3*jstride+1+1*kstride] = gout27;
    eri_ij[4+1*jstride+1*kstride] = gout28;
    //eri_ji[4*jstride+1+1*kstride] = gout28;
    eri_ij[5+1*jstride+1*kstride] = gout29;
    //eri_ji[5*jstride+1+1*kstride] = gout29;
    eri_ij[2*jstride+1*kstride] = gout30;
    //eri_ji[2+1*kstride] = gout30;
    eri_ij[1+2*jstride+1*kstride] = gout31;
    //eri_ji[1*jstride+2+1*kstride] = gout31;
    eri_ij[2+2*jstride+1*kstride] = gout32;
    //eri_ji[2*jstride+2+1*kstride] = gout32;
    eri_ij[3+2*jstride+1*kstride] = gout33;
    //eri_ji[3*jstride+2+1*kstride] = gout33;
    eri_ij[4+2*jstride+1*kstride] = gout34;
    //eri_ji[4*jstride+2+1*kstride] = gout34;
    eri_ij[5+2*jstride+1*kstride] = gout35;
    //eri_ji[5*jstride+2+1*kstride] = gout35;
    eri_ij[2*kstride] = gout36;
    //eri_ji[2*kstride] = gout36;
    eri_ij[1+2*kstride] = gout37;
    //eri_ji[1*jstride+2*kstride] = gout37;
    eri_ij[2+2*kstride] = gout38;
    //eri_ji[2*jstride+2*kstride] = gout38;
    eri_ij[3+2*kstride] = gout39;
    //eri_ji[3*jstride+2*kstride] = gout39;
    eri_ij[4+2*kstride] = gout40;
    //eri_ji[4*jstride+2*kstride] = gout40;
    eri_ij[5+2*kstride] = gout41;
    //eri_ji[5*jstride+2*kstride] = gout41;
    eri_ij[1*jstride+2*kstride] = gout42;
    //eri_ji[1+2*kstride] = gout42;
    eri_ij[1+1*jstride+2*kstride] = gout43;
    //eri_ji[1*jstride+1+2*kstride] = gout43;
    eri_ij[2+1*jstride+2*kstride] = gout44;
    //eri_ji[2*jstride+1+2*kstride] = gout44;
    eri_ij[3+1*jstride+2*kstride] = gout45;
    //eri_ji[3*jstride+1+2*kstride] = gout45;
    eri_ij[4+1*jstride+2*kstride] = gout46;
    //eri_ji[4*jstride+1+2*kstride] = gout46;
    eri_ij[5+1*jstride+2*kstride] = gout47;
    //eri_ji[5*jstride+1+2*kstride] = gout47;
    eri_ij[2*jstride+2*kstride] = gout48;
    //eri_ji[2+2*kstride] = gout48;
    eri_ij[1+2*jstride+2*kstride] = gout49;
    //eri_ji[1*jstride+2+2*kstride] = gout49;
    eri_ij[2+2*jstride+2*kstride] = gout50;
    //eri_ji[2*jstride+2+2*kstride] = gout50;
    eri_ij[3+2*jstride+2*kstride] = gout51;
    //eri_ji[3*jstride+2+2*kstride] = gout51;
    eri_ij[4+2*jstride+2*kstride] = gout52;
    //eri_ji[4*jstride+2+2*kstride] = gout52;
    eri_ij[5+2*jstride+2*kstride] = gout53;
    //eri_ji[5*jstride+2+2*kstride] = gout53;
    eri_ij[3*kstride] = gout54;
    //eri_ji[3*kstride] = gout54;
    eri_ij[1+3*kstride] = gout55;
    //eri_ji[1*jstride+3*kstride] = gout55;
    eri_ij[2+3*kstride] = gout56;
    //eri_ji[2*jstride+3*kstride] = gout56;
    eri_ij[3+3*kstride] = gout57;
    //eri_ji[3*jstride+3*kstride] = gout57;
    eri_ij[4+3*kstride] = gout58;
    //eri_ji[4*jstride+3*kstride] = gout58;
    eri_ij[5+3*kstride] = gout59;
    //eri_ji[5*jstride+3*kstride] = gout59;
    eri_ij[1*jstride+3*kstride] = gout60;
    //eri_ji[1+3*kstride] = gout60;
    eri_ij[1+1*jstride+3*kstride] = gout61;
    //eri_ji[1*jstride+1+3*kstride] = gout61;
    eri_ij[2+1*jstride+3*kstride] = gout62;
    //eri_ji[2*jstride+1+3*kstride] = gout62;
    eri_ij[3+1*jstride+3*kstride] = gout63;
    //eri_ji[3*jstride+1+3*kstride] = gout63;
    eri_ij[4+1*jstride+3*kstride] = gout64;
    //eri_ji[4*jstride+1+3*kstride] = gout64;
    eri_ij[5+1*jstride+3*kstride] = gout65;
    //eri_ji[5*jstride+1+3*kstride] = gout65;
    eri_ij[2*jstride+3*kstride] = gout66;
    //eri_ji[2+3*kstride] = gout66;
    eri_ij[1+2*jstride+3*kstride] = gout67;
    //eri_ji[1*jstride+2+3*kstride] = gout67;
    eri_ij[2+2*jstride+3*kstride] = gout68;
    //eri_ji[2*jstride+2+3*kstride] = gout68;
    eri_ij[3+2*jstride+3*kstride] = gout69;
    //eri_ji[3*jstride+2+3*kstride] = gout69;
    eri_ij[4+2*jstride+3*kstride] = gout70;
    //eri_ji[4*jstride+2+3*kstride] = gout70;
    eri_ij[5+2*jstride+3*kstride] = gout71;
    //eri_ji[5*jstride+2+3*kstride] = gout71;
    eri_ij[4*kstride] = gout72;
    //eri_ji[4*kstride] = gout72;
    eri_ij[1+4*kstride] = gout73;
    //eri_ji[1*jstride+4*kstride] = gout73;
    eri_ij[2+4*kstride] = gout74;
    //eri_ji[2*jstride+4*kstride] = gout74;
    eri_ij[3+4*kstride] = gout75;
    //eri_ji[3*jstride+4*kstride] = gout75;
    eri_ij[4+4*kstride] = gout76;
    //eri_ji[4*jstride+4*kstride] = gout76;
    eri_ij[5+4*kstride] = gout77;
    //eri_ji[5*jstride+4*kstride] = gout77;
    eri_ij[1*jstride+4*kstride] = gout78;
    //eri_ji[1+4*kstride] = gout78;
    eri_ij[1+1*jstride+4*kstride] = gout79;
    //eri_ji[1*jstride+1+4*kstride] = gout79;
    eri_ij[2+1*jstride+4*kstride] = gout80;
    //eri_ji[2*jstride+1+4*kstride] = gout80;
    eri_ij[3+1*jstride+4*kstride] = gout81;
    //eri_ji[3*jstride+1+4*kstride] = gout81;
    eri_ij[4+1*jstride+4*kstride] = gout82;
    //eri_ji[4*jstride+1+4*kstride] = gout82;
    eri_ij[5+1*jstride+4*kstride] = gout83;
    //eri_ji[5*jstride+1+4*kstride] = gout83;
    eri_ij[2*jstride+4*kstride] = gout84;
    //eri_ji[2+4*kstride] = gout84;
    eri_ij[1+2*jstride+4*kstride] = gout85;
    //eri_ji[1*jstride+2+4*kstride] = gout85;
    eri_ij[2+2*jstride+4*kstride] = gout86;
    //eri_ji[2*jstride+2+4*kstride] = gout86;
    eri_ij[3+2*jstride+4*kstride] = gout87;
    //eri_ji[3*jstride+2+4*kstride] = gout87;
    eri_ij[4+2*jstride+4*kstride] = gout88;
    //eri_ji[4*jstride+2+4*kstride] = gout88;
    eri_ij[5+2*jstride+4*kstride] = gout89;
    //eri_ji[5*jstride+2+4*kstride] = gout89;
    eri_ij[5*kstride] = gout90;
    //eri_ji[5*kstride] = gout90;
    eri_ij[1+5*kstride] = gout91;
    //eri_ji[1*jstride+5*kstride] = gout91;
    eri_ij[2+5*kstride] = gout92;
    //eri_ji[2*jstride+5*kstride] = gout92;
    eri_ij[3+5*kstride] = gout93;
    //eri_ji[3*jstride+5*kstride] = gout93;
    eri_ij[4+5*kstride] = gout94;
    //eri_ji[4*jstride+5*kstride] = gout94;
    eri_ij[5+5*kstride] = gout95;
    //eri_ji[5*jstride+5*kstride] = gout95;
    eri_ij[1*jstride+5*kstride] = gout96;
    //eri_ji[1+5*kstride] = gout96;
    eri_ij[1+1*jstride+5*kstride] = gout97;
    //eri_ji[1*jstride+1+5*kstride] = gout97;
    eri_ij[2+1*jstride+5*kstride] = gout98;
    //eri_ji[2*jstride+1+5*kstride] = gout98;
    eri_ij[3+1*jstride+5*kstride] = gout99;
    //eri_ji[3*jstride+1+5*kstride] = gout99;
    eri_ij[4+1*jstride+5*kstride] = gout100;
    //eri_ji[4*jstride+1+5*kstride] = gout100;
    eri_ij[5+1*jstride+5*kstride] = gout101;
    //eri_ji[5*jstride+1+5*kstride] = gout101;
    eri_ij[2*jstride+5*kstride] = gout102;
    //eri_ji[2+5*kstride] = gout102;
    eri_ij[1+2*jstride+5*kstride] = gout103;
    //eri_ji[1*jstride+2+5*kstride] = gout103;
    eri_ij[2+2*jstride+5*kstride] = gout104;
    //eri_ji[2*jstride+2+5*kstride] = gout104;
    eri_ij[3+2*jstride+5*kstride] = gout105;
    //eri_ji[3*jstride+2+5*kstride] = gout105;
    eri_ij[4+2*jstride+5*kstride] = gout106;
    //eri_ji[4*jstride+2+5*kstride] = gout106;
    eri_ij[5+2*jstride+5*kstride] = gout107;
    //eri_ji[5*jstride+2+5*kstride] = gout107;
}

__global__
static void GINTfill_int2e_kernel2200(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xixj = xi - bas_x[jsh];
    double yiyj = yi - bas_y[jsh];
    double zizj = zi - bas_z[jsh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double b10 = b00 + tmp4 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c00x * c00x + b10;
            double g_3 = c00x + xixj;
            double g_4 = c00x * (c00x + xixj) + b10;
            double g_5 = c00x * (2 * b10 + g_2) + xixj * g_2;
            double g_6 = xixj * (xixj + c00x) + xixj * c00x + c00x * c00x + b10;
            double g_7 = xixj * (xixj * c00x + c00x * c00x + b10) + xixj * g_2 + c00x * g_2 + 2 * b10 * c00x;
            double g_8 = xixj * (xixj * g_2 + c00x * g_2 + 2 * b10 * c00x) + xixj * (c00x * g_2 + 2 * b10 * c00x) + c00x * (c00x * g_2 + 2 * b10 * c00x) + 3 * b10 * g_2;
            double g_9 = 1;
            double g_10 = c00y;
            double g_11 = c00y * c00y + b10;
            double g_12 = c00y + yiyj;
            double g_13 = c00y * (c00y + yiyj) + b10;
            double g_14 = c00y * (2 * b10 + g_11) + yiyj * g_11;
            double g_15 = yiyj * (yiyj + c00y) + yiyj * c00y + c00y * c00y + b10;
            double g_16 = yiyj * (yiyj * c00y + c00y * c00y + b10) + yiyj * g_11 + c00y * g_11 + 2 * b10 * c00y;
            double g_17 = yiyj * (yiyj * g_11 + c00y * g_11 + 2 * b10 * c00y) + yiyj * (c00y * g_11 + 2 * b10 * c00y) + c00y * (c00y * g_11 + 2 * b10 * c00y) + 3 * b10 * g_11;
            double g_18 = weight0 * fac;
            double g_19 = c00z * g_18;
            double g_20 = b10 * g_18 + c00z * g_19;
            double g_21 = g_18 * (c00z + zizj);
            double g_22 = b10 * g_18 + c00z * g_19 + zizj * g_19;
            double g_23 = 2 * b10 * g_19 + c00z * g_20 + zizj * g_20;
            double g_24 = zizj * (zizj * g_18 + c00z * g_18) + zizj * g_19 + c00z * g_19 + b10 * g_18;
            double g_25 = zizj * (zizj * g_19 + c00z * g_19 + b10 * g_18) + zizj * g_20 + c00z * g_20 + 2 * b10 * g_19;
            double g_26 = zizj * (zizj * g_20 + c00z * g_20 + 2 * b10 * g_19) + zizj * (c00z * g_20 + 2 * b10 * g_19) + c00z * (c00z * g_20 + 2 * b10 * g_19) + 3 * b10 * g_20;
            gout0 += g_8 * g_9 * g_18;
            gout1 += g_7 * g_10 * g_18;
            gout2 += g_7 * g_9 * g_19;
            gout3 += g_6 * g_11 * g_18;
            gout4 += g_6 * g_10 * g_19;
            gout5 += g_6 * g_9 * g_20;
            gout6 += g_5 * g_12 * g_18;
            gout7 += g_4 * g_13 * g_18;
            gout8 += g_4 * g_12 * g_19;
            gout9 += g_3 * g_14 * g_18;
            gout10 += g_3 * g_13 * g_19;
            gout11 += g_3 * g_12 * g_20;
            gout12 += g_5 * g_9 * g_21;
            gout13 += g_4 * g_10 * g_21;
            gout14 += g_4 * g_9 * g_22;
            gout15 += g_3 * g_11 * g_21;
            gout16 += g_3 * g_10 * g_22;
            gout17 += g_3 * g_9 * g_23;
            gout18 += g_2 * g_15 * g_18;
            gout19 += g_1 * g_16 * g_18;
            gout20 += g_1 * g_15 * g_19;
            gout21 += g_0 * g_17 * g_18;
            gout22 += g_0 * g_16 * g_19;
            gout23 += g_0 * g_15 * g_20;
            gout24 += g_2 * g_12 * g_21;
            gout25 += g_1 * g_13 * g_21;
            gout26 += g_1 * g_12 * g_22;
            gout27 += g_0 * g_14 * g_21;
            gout28 += g_0 * g_13 * g_22;
            gout29 += g_0 * g_12 * g_23;
            gout30 += g_2 * g_9 * g_24;
            gout31 += g_1 * g_10 * g_24;
            gout32 += g_1 * g_9 * g_25;
            gout33 += g_0 * g_11 * g_24;
            gout34 += g_0 * g_10 * g_25;
            gout35 += g_0 * g_9 * g_26;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[3] = gout3;
    //eri_ji[3*jstride] = gout3;
    eri_ij[4] = gout4;
    //eri_ji[4*jstride] = gout4;
    eri_ij[5] = gout5;
    //eri_ji[5*jstride] = gout5;
    eri_ij[1*jstride] = gout6;
    //eri_ji[1] = gout6;
    eri_ij[1+1*jstride] = gout7;
    //eri_ji[1*jstride+1] = gout7;
    eri_ij[2+1*jstride] = gout8;
    //eri_ji[2*jstride+1] = gout8;
    eri_ij[3+1*jstride] = gout9;
    //eri_ji[3*jstride+1] = gout9;
    eri_ij[4+1*jstride] = gout10;
    //eri_ji[4*jstride+1] = gout10;
    eri_ij[5+1*jstride] = gout11;
    //eri_ji[5*jstride+1] = gout11;
    eri_ij[2*jstride] = gout12;
    //eri_ji[2] = gout12;
    eri_ij[1+2*jstride] = gout13;
    //eri_ji[1*jstride+2] = gout13;
    eri_ij[2+2*jstride] = gout14;
    //eri_ji[2*jstride+2] = gout14;
    eri_ij[3+2*jstride] = gout15;
    //eri_ji[3*jstride+2] = gout15;
    eri_ij[4+2*jstride] = gout16;
    //eri_ji[4*jstride+2] = gout16;
    eri_ij[5+2*jstride] = gout17;
    //eri_ji[5*jstride+2] = gout17;
    eri_ij[3*jstride] = gout18;
    //eri_ji[3] = gout18;
    eri_ij[1+3*jstride] = gout19;
    //eri_ji[1*jstride+3] = gout19;
    eri_ij[2+3*jstride] = gout20;
    //eri_ji[2*jstride+3] = gout20;
    eri_ij[3+3*jstride] = gout21;
    //eri_ji[3*jstride+3] = gout21;
    eri_ij[4+3*jstride] = gout22;
    //eri_ji[4*jstride+3] = gout22;
    eri_ij[5+3*jstride] = gout23;
    //eri_ji[5*jstride+3] = gout23;
    eri_ij[4*jstride] = gout24;
    //eri_ji[4] = gout24;
    eri_ij[1+4*jstride] = gout25;
    //eri_ji[1*jstride+4] = gout25;
    eri_ij[2+4*jstride] = gout26;
    //eri_ji[2*jstride+4] = gout26;
    eri_ij[3+4*jstride] = gout27;
    //eri_ji[3*jstride+4] = gout27;
    eri_ij[4+4*jstride] = gout28;
    //eri_ji[4*jstride+4] = gout28;
    eri_ij[5+4*jstride] = gout29;
    //eri_ji[5*jstride+4] = gout29;
    eri_ij[5*jstride] = gout30;
    //eri_ji[5] = gout30;
    eri_ij[1+5*jstride] = gout31;
    //eri_ji[1*jstride+5] = gout31;
    eri_ij[2+5*jstride] = gout32;
    //eri_ji[2*jstride+5] = gout32;
    eri_ij[3+5*jstride] = gout33;
    //eri_ji[3*jstride+5] = gout33;
    eri_ij[4+5*jstride] = gout34;
    //eri_ji[4*jstride+5] = gout34;
    eri_ij[5+5*jstride] = gout35;
    //eri_ji[5*jstride+5] = gout35;
}

__global__
static void GINTfill_int2e_kernel2210(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double gout36 = 0;
    double gout37 = 0;
    double gout38 = 0;
    double gout39 = 0;
    double gout40 = 0;
    double gout41 = 0;
    double gout42 = 0;
    double gout43 = 0;
    double gout44 = 0;
    double gout45 = 0;
    double gout46 = 0;
    double gout47 = 0;
    double gout48 = 0;
    double gout49 = 0;
    double gout50 = 0;
    double gout51 = 0;
    double gout52 = 0;
    double gout53 = 0;
    double gout54 = 0;
    double gout55 = 0;
    double gout56 = 0;
    double gout57 = 0;
    double gout58 = 0;
    double gout59 = 0;
    double gout60 = 0;
    double gout61 = 0;
    double gout62 = 0;
    double gout63 = 0;
    double gout64 = 0;
    double gout65 = 0;
    double gout66 = 0;
    double gout67 = 0;
    double gout68 = 0;
    double gout69 = 0;
    double gout70 = 0;
    double gout71 = 0;
    double gout72 = 0;
    double gout73 = 0;
    double gout74 = 0;
    double gout75 = 0;
    double gout76 = 0;
    double gout77 = 0;
    double gout78 = 0;
    double gout79 = 0;
    double gout80 = 0;
    double gout81 = 0;
    double gout82 = 0;
    double gout83 = 0;
    double gout84 = 0;
    double gout85 = 0;
    double gout86 = 0;
    double gout87 = 0;
    double gout88 = 0;
    double gout89 = 0;
    double gout90 = 0;
    double gout91 = 0;
    double gout92 = 0;
    double gout93 = 0;
    double gout94 = 0;
    double gout95 = 0;
    double gout96 = 0;
    double gout97 = 0;
    double gout98 = 0;
    double gout99 = 0;
    double gout100 = 0;
    double gout101 = 0;
    double gout102 = 0;
    double gout103 = 0;
    double gout104 = 0;
    double gout105 = 0;
    double gout106 = 0;
    double gout107 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xixj = xi - bas_x[jsh];
    double yiyj = yi - bas_y[jsh];
    double zizj = zi - bas_z[jsh];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double b10 = b00 + tmp4 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c00x * c00x + b10;
            double g_3 = c00x + xixj;
            double g_4 = c00x * (c00x + xixj) + b10;
            double g_5 = c00x * (2 * b10 + g_2) + xixj * g_2;
            double g_6 = xixj * (xixj + c00x) + xixj * c00x + c00x * c00x + b10;
            double g_7 = xixj * (xixj * c00x + c00x * c00x + b10) + xixj * g_2 + c00x * g_2 + 2 * b10 * c00x;
            double g_8 = xixj * (xixj * g_2 + c00x * g_2 + 2 * b10 * c00x) + xixj * (c00x * g_2 + 2 * b10 * c00x) + c00x * (c00x * g_2 + 2 * b10 * c00x) + 3 * b10 * g_2;
            double g_9 = c0px;
            double g_10 = c0px * c00x + b00;
            double g_11 = b00 * c00x + b10 * c0px + c00x * g_10;
            double g_12 = c0px * (c00x + xixj) + b00;
            double g_13 = b00 * c00x + b10 * c0px + c00x * g_10 + xixj * g_10;
            double g_14 = 2 * b10 * g_10 + b00 * g_2 + c00x * g_11 + xixj * g_11;
            double g_15 = xixj * (xixj * c0px + c0px * c00x + b00) + xixj * g_10 + c00x * g_10 + b10 * c0px + b00 * c00x;
            double g_16 = xixj * (xixj * g_10 + c00x * g_10 + b10 * c0px + b00 * c00x) + xixj * g_11 + c00x * g_11 + 2 * b10*g_10 + b00 * g_2;
            double g_17 = xixj * (xixj * g_11 + c00x * g_11 + 2 * b10*g_10 + b00 * g_2) + xixj * (c00x * g_11 + 2 * b10*g_10 + b00 * g_2) + c00x * (c00x * g_11 + 2 * b10*g_10 + b00 * g_2) + 3 * b10*g_11 + b00 * (c00x * g_2 + 2 * b10 * c00x);
            double g_18 = 1;
            double g_19 = c00y;
            double g_20 = c00y * c00y + b10;
            double g_21 = c00y + yiyj;
            double g_22 = c00y * (c00y + yiyj) + b10;
            double g_23 = c00y * (2 * b10 + g_20) + yiyj * g_20;
            double g_24 = yiyj * (yiyj + c00y) + yiyj * c00y + c00y * c00y + b10;
            double g_25 = yiyj * (yiyj * c00y + c00y * c00y + b10) + yiyj * g_20 + c00y * g_20 + 2 * b10 * c00y;
            double g_26 = yiyj * (yiyj * g_20 + c00y * g_20 + 2 * b10 * c00y) + yiyj * (c00y * g_20 + 2 * b10 * c00y) + c00y * (c00y * g_20 + 2 * b10 * c00y) + 3 * b10 * g_20;
            double g_27 = c0py;
            double g_28 = c0py * c00y + b00;
            double g_29 = b00 * c00y + b10 * c0py + c00y * g_28;
            double g_30 = c0py * (c00y + yiyj) + b00;
            double g_31 = b00 * c00y + b10 * c0py + c00y * g_28 + yiyj * g_28;
            double g_32 = 2 * b10 * g_28 + b00 * g_20 + c00y * g_29 + yiyj * g_29;
            double g_33 = yiyj * (yiyj * c0py + c0py * c00y + b00) + yiyj * g_28 + c00y * g_28 + b10 * c0py + b00 * c00y;
            double g_34 = yiyj * (yiyj * g_28 + c00y * g_28 + b10 * c0py + b00 * c00y) + yiyj * g_29 + c00y * g_29 + 2 * b10*g_28 + b00 * g_20;
            double g_35 = yiyj * (yiyj * g_29 + c00y * g_29 + 2 * b10*g_28 + b00 * g_20) + yiyj * (c00y * g_29 + 2 * b10*g_28 + b00 * g_20) + c00y * (c00y * g_29 + 2 * b10*g_28 + b00 * g_20) + 3 * b10*g_29 + b00 * (c00y * g_20 + 2 * b10 * c00y);
            double g_36 = weight0 * fac;
            double g_37 = c00z * g_36;
            double g_38 = b10 * g_36 + c00z * g_37;
            double g_39 = g_36 * (c00z + zizj);
            double g_40 = b10 * g_36 + c00z * g_37 + zizj * g_37;
            double g_41 = 2 * b10 * g_37 + c00z * g_38 + zizj * g_38;
            double g_42 = zizj * (zizj * g_36 + c00z * g_36) + zizj * g_37 + c00z * g_37 + b10 * g_36;
            double g_43 = zizj * (zizj * g_37 + c00z * g_37 + b10 * g_36) + zizj * g_38 + c00z * g_38 + 2 * b10 * g_37;
            double g_44 = zizj * (zizj * g_38 + c00z * g_38 + 2 * b10 * g_37) + zizj * (c00z * g_38 + 2 * b10 * g_37) + c00z * (c00z * g_38 + 2 * b10 * g_37) + 3 * b10 * g_38;
            double g_45 = c0pz * g_36;
            double g_46 = b00 * g_36 + c0pz * g_37;
            double g_47 = b00 * g_37 + b10 * g_45 + c00z * g_46;
            double g_48 = b00 * g_36 + c0pz * g_37 + zizj * g_45;
            double g_49 = b00 * g_37 + b10 * g_45 + c00z * g_46 + zizj * g_46;
            double g_50 = 2 * b10 * g_46 + b00 * g_38 + c00z * g_47 + zizj * g_47;
            double g_51 = zizj * (zizj * g_45 + c0pz * g_37 + b00 * g_36) + zizj * g_46 + c00z * g_46 + b10 * g_45 + b00 * g_37;
            double g_52 = zizj * (zizj * g_46 + c00z * g_46 + b10 * g_45 + b00 * g_37) + zizj * g_47 + c00z * g_47 + 2 * b10*g_46 + b00 * g_38;
            double g_53 = zizj * (zizj * g_47 + c00z * g_47 + 2 * b10*g_46 + b00 * g_38) + zizj * (c00z * g_47 + 2 * b10*g_46 + b00 * g_38) + c00z * (c00z * g_47 + 2 * b10*g_46 + b00 * g_38) + 3 * b10*g_47 + b00 * (c00z * g_38 + 2 * b10 * g_37);
            gout0 += g_17 * g_18 * g_36;
            gout1 += g_16 * g_19 * g_36;
            gout2 += g_16 * g_18 * g_37;
            gout3 += g_15 * g_20 * g_36;
            gout4 += g_15 * g_19 * g_37;
            gout5 += g_15 * g_18 * g_38;
            gout6 += g_14 * g_21 * g_36;
            gout7 += g_13 * g_22 * g_36;
            gout8 += g_13 * g_21 * g_37;
            gout9 += g_12 * g_23 * g_36;
            gout10 += g_12 * g_22 * g_37;
            gout11 += g_12 * g_21 * g_38;
            gout12 += g_14 * g_18 * g_39;
            gout13 += g_13 * g_19 * g_39;
            gout14 += g_13 * g_18 * g_40;
            gout15 += g_12 * g_20 * g_39;
            gout16 += g_12 * g_19 * g_40;
            gout17 += g_12 * g_18 * g_41;
            gout18 += g_11 * g_24 * g_36;
            gout19 += g_10 * g_25 * g_36;
            gout20 += g_10 * g_24 * g_37;
            gout21 += g_9 * g_26 * g_36;
            gout22 += g_9 * g_25 * g_37;
            gout23 += g_9 * g_24 * g_38;
            gout24 += g_11 * g_21 * g_39;
            gout25 += g_10 * g_22 * g_39;
            gout26 += g_10 * g_21 * g_40;
            gout27 += g_9 * g_23 * g_39;
            gout28 += g_9 * g_22 * g_40;
            gout29 += g_9 * g_21 * g_41;
            gout30 += g_11 * g_18 * g_42;
            gout31 += g_10 * g_19 * g_42;
            gout32 += g_10 * g_18 * g_43;
            gout33 += g_9 * g_20 * g_42;
            gout34 += g_9 * g_19 * g_43;
            gout35 += g_9 * g_18 * g_44;
            gout36 += g_8 * g_27 * g_36;
            gout37 += g_7 * g_28 * g_36;
            gout38 += g_7 * g_27 * g_37;
            gout39 += g_6 * g_29 * g_36;
            gout40 += g_6 * g_28 * g_37;
            gout41 += g_6 * g_27 * g_38;
            gout42 += g_5 * g_30 * g_36;
            gout43 += g_4 * g_31 * g_36;
            gout44 += g_4 * g_30 * g_37;
            gout45 += g_3 * g_32 * g_36;
            gout46 += g_3 * g_31 * g_37;
            gout47 += g_3 * g_30 * g_38;
            gout48 += g_5 * g_27 * g_39;
            gout49 += g_4 * g_28 * g_39;
            gout50 += g_4 * g_27 * g_40;
            gout51 += g_3 * g_29 * g_39;
            gout52 += g_3 * g_28 * g_40;
            gout53 += g_3 * g_27 * g_41;
            gout54 += g_2 * g_33 * g_36;
            gout55 += g_1 * g_34 * g_36;
            gout56 += g_1 * g_33 * g_37;
            gout57 += g_0 * g_35 * g_36;
            gout58 += g_0 * g_34 * g_37;
            gout59 += g_0 * g_33 * g_38;
            gout60 += g_2 * g_30 * g_39;
            gout61 += g_1 * g_31 * g_39;
            gout62 += g_1 * g_30 * g_40;
            gout63 += g_0 * g_32 * g_39;
            gout64 += g_0 * g_31 * g_40;
            gout65 += g_0 * g_30 * g_41;
            gout66 += g_2 * g_27 * g_42;
            gout67 += g_1 * g_28 * g_42;
            gout68 += g_1 * g_27 * g_43;
            gout69 += g_0 * g_29 * g_42;
            gout70 += g_0 * g_28 * g_43;
            gout71 += g_0 * g_27 * g_44;
            gout72 += g_8 * g_18 * g_45;
            gout73 += g_7 * g_19 * g_45;
            gout74 += g_7 * g_18 * g_46;
            gout75 += g_6 * g_20 * g_45;
            gout76 += g_6 * g_19 * g_46;
            gout77 += g_6 * g_18 * g_47;
            gout78 += g_5 * g_21 * g_45;
            gout79 += g_4 * g_22 * g_45;
            gout80 += g_4 * g_21 * g_46;
            gout81 += g_3 * g_23 * g_45;
            gout82 += g_3 * g_22 * g_46;
            gout83 += g_3 * g_21 * g_47;
            gout84 += g_5 * g_18 * g_48;
            gout85 += g_4 * g_19 * g_48;
            gout86 += g_4 * g_18 * g_49;
            gout87 += g_3 * g_20 * g_48;
            gout88 += g_3 * g_19 * g_49;
            gout89 += g_3 * g_18 * g_50;
            gout90 += g_2 * g_24 * g_45;
            gout91 += g_1 * g_25 * g_45;
            gout92 += g_1 * g_24 * g_46;
            gout93 += g_0 * g_26 * g_45;
            gout94 += g_0 * g_25 * g_46;
            gout95 += g_0 * g_24 * g_47;
            gout96 += g_2 * g_21 * g_48;
            gout97 += g_1 * g_22 * g_48;
            gout98 += g_1 * g_21 * g_49;
            gout99 += g_0 * g_23 * g_48;
            gout100 += g_0 * g_22 * g_49;
            gout101 += g_0 * g_21 * g_50;
            gout102 += g_2 * g_18 * g_51;
            gout103 += g_1 * g_19 * g_51;
            gout104 += g_1 * g_18 * g_52;
            gout105 += g_0 * g_20 * g_51;
            gout106 += g_0 * g_19 * g_52;
            gout107 += g_0 * g_18 * g_53;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[3] = gout3;
    //eri_ji[3*jstride] = gout3;
    eri_ij[4] = gout4;
    //eri_ji[4*jstride] = gout4;
    eri_ij[5] = gout5;
    //eri_ji[5*jstride] = gout5;
    eri_ij[1*jstride] = gout6;
    //eri_ji[1] = gout6;
    eri_ij[1+1*jstride] = gout7;
    //eri_ji[1*jstride+1] = gout7;
    eri_ij[2+1*jstride] = gout8;
    //eri_ji[2*jstride+1] = gout8;
    eri_ij[3+1*jstride] = gout9;
    //eri_ji[3*jstride+1] = gout9;
    eri_ij[4+1*jstride] = gout10;
    //eri_ji[4*jstride+1] = gout10;
    eri_ij[5+1*jstride] = gout11;
    //eri_ji[5*jstride+1] = gout11;
    eri_ij[2*jstride] = gout12;
    //eri_ji[2] = gout12;
    eri_ij[1+2*jstride] = gout13;
    //eri_ji[1*jstride+2] = gout13;
    eri_ij[2+2*jstride] = gout14;
    //eri_ji[2*jstride+2] = gout14;
    eri_ij[3+2*jstride] = gout15;
    //eri_ji[3*jstride+2] = gout15;
    eri_ij[4+2*jstride] = gout16;
    //eri_ji[4*jstride+2] = gout16;
    eri_ij[5+2*jstride] = gout17;
    //eri_ji[5*jstride+2] = gout17;
    eri_ij[3*jstride] = gout18;
    //eri_ji[3] = gout18;
    eri_ij[1+3*jstride] = gout19;
    //eri_ji[1*jstride+3] = gout19;
    eri_ij[2+3*jstride] = gout20;
    //eri_ji[2*jstride+3] = gout20;
    eri_ij[3+3*jstride] = gout21;
    //eri_ji[3*jstride+3] = gout21;
    eri_ij[4+3*jstride] = gout22;
    //eri_ji[4*jstride+3] = gout22;
    eri_ij[5+3*jstride] = gout23;
    //eri_ji[5*jstride+3] = gout23;
    eri_ij[4*jstride] = gout24;
    //eri_ji[4] = gout24;
    eri_ij[1+4*jstride] = gout25;
    //eri_ji[1*jstride+4] = gout25;
    eri_ij[2+4*jstride] = gout26;
    //eri_ji[2*jstride+4] = gout26;
    eri_ij[3+4*jstride] = gout27;
    //eri_ji[3*jstride+4] = gout27;
    eri_ij[4+4*jstride] = gout28;
    //eri_ji[4*jstride+4] = gout28;
    eri_ij[5+4*jstride] = gout29;
    //eri_ji[5*jstride+4] = gout29;
    eri_ij[5*jstride] = gout30;
    //eri_ji[5] = gout30;
    eri_ij[1+5*jstride] = gout31;
    //eri_ji[1*jstride+5] = gout31;
    eri_ij[2+5*jstride] = gout32;
    //eri_ji[2*jstride+5] = gout32;
    eri_ij[3+5*jstride] = gout33;
    //eri_ji[3*jstride+5] = gout33;
    eri_ij[4+5*jstride] = gout34;
    //eri_ji[4*jstride+5] = gout34;
    eri_ij[5+5*jstride] = gout35;
    //eri_ji[5*jstride+5] = gout35;
    eri_ij[1*kstride] = gout36;
    //eri_ji[1*kstride] = gout36;
    eri_ij[1+1*kstride] = gout37;
    //eri_ji[1*jstride+1*kstride] = gout37;
    eri_ij[2+1*kstride] = gout38;
    //eri_ji[2*jstride+1*kstride] = gout38;
    eri_ij[3+1*kstride] = gout39;
    //eri_ji[3*jstride+1*kstride] = gout39;
    eri_ij[4+1*kstride] = gout40;
    //eri_ji[4*jstride+1*kstride] = gout40;
    eri_ij[5+1*kstride] = gout41;
    //eri_ji[5*jstride+1*kstride] = gout41;
    eri_ij[1*jstride+1*kstride] = gout42;
    //eri_ji[1+1*kstride] = gout42;
    eri_ij[1+1*jstride+1*kstride] = gout43;
    //eri_ji[1*jstride+1+1*kstride] = gout43;
    eri_ij[2+1*jstride+1*kstride] = gout44;
    //eri_ji[2*jstride+1+1*kstride] = gout44;
    eri_ij[3+1*jstride+1*kstride] = gout45;
    //eri_ji[3*jstride+1+1*kstride] = gout45;
    eri_ij[4+1*jstride+1*kstride] = gout46;
    //eri_ji[4*jstride+1+1*kstride] = gout46;
    eri_ij[5+1*jstride+1*kstride] = gout47;
    //eri_ji[5*jstride+1+1*kstride] = gout47;
    eri_ij[2*jstride+1*kstride] = gout48;
    //eri_ji[2+1*kstride] = gout48;
    eri_ij[1+2*jstride+1*kstride] = gout49;
    //eri_ji[1*jstride+2+1*kstride] = gout49;
    eri_ij[2+2*jstride+1*kstride] = gout50;
    //eri_ji[2*jstride+2+1*kstride] = gout50;
    eri_ij[3+2*jstride+1*kstride] = gout51;
    //eri_ji[3*jstride+2+1*kstride] = gout51;
    eri_ij[4+2*jstride+1*kstride] = gout52;
    //eri_ji[4*jstride+2+1*kstride] = gout52;
    eri_ij[5+2*jstride+1*kstride] = gout53;
    //eri_ji[5*jstride+2+1*kstride] = gout53;
    eri_ij[3*jstride+1*kstride] = gout54;
    //eri_ji[3+1*kstride] = gout54;
    eri_ij[1+3*jstride+1*kstride] = gout55;
    //eri_ji[1*jstride+3+1*kstride] = gout55;
    eri_ij[2+3*jstride+1*kstride] = gout56;
    //eri_ji[2*jstride+3+1*kstride] = gout56;
    eri_ij[3+3*jstride+1*kstride] = gout57;
    //eri_ji[3*jstride+3+1*kstride] = gout57;
    eri_ij[4+3*jstride+1*kstride] = gout58;
    //eri_ji[4*jstride+3+1*kstride] = gout58;
    eri_ij[5+3*jstride+1*kstride] = gout59;
    //eri_ji[5*jstride+3+1*kstride] = gout59;
    eri_ij[4*jstride+1*kstride] = gout60;
    //eri_ji[4+1*kstride] = gout60;
    eri_ij[1+4*jstride+1*kstride] = gout61;
    //eri_ji[1*jstride+4+1*kstride] = gout61;
    eri_ij[2+4*jstride+1*kstride] = gout62;
    //eri_ji[2*jstride+4+1*kstride] = gout62;
    eri_ij[3+4*jstride+1*kstride] = gout63;
    //eri_ji[3*jstride+4+1*kstride] = gout63;
    eri_ij[4+4*jstride+1*kstride] = gout64;
    //eri_ji[4*jstride+4+1*kstride] = gout64;
    eri_ij[5+4*jstride+1*kstride] = gout65;
    //eri_ji[5*jstride+4+1*kstride] = gout65;
    eri_ij[5*jstride+1*kstride] = gout66;
    //eri_ji[5+1*kstride] = gout66;
    eri_ij[1+5*jstride+1*kstride] = gout67;
    //eri_ji[1*jstride+5+1*kstride] = gout67;
    eri_ij[2+5*jstride+1*kstride] = gout68;
    //eri_ji[2*jstride+5+1*kstride] = gout68;
    eri_ij[3+5*jstride+1*kstride] = gout69;
    //eri_ji[3*jstride+5+1*kstride] = gout69;
    eri_ij[4+5*jstride+1*kstride] = gout70;
    //eri_ji[4*jstride+5+1*kstride] = gout70;
    eri_ij[5+5*jstride+1*kstride] = gout71;
    //eri_ji[5*jstride+5+1*kstride] = gout71;
    eri_ij[2*kstride] = gout72;
    //eri_ji[2*kstride] = gout72;
    eri_ij[1+2*kstride] = gout73;
    //eri_ji[1*jstride+2*kstride] = gout73;
    eri_ij[2+2*kstride] = gout74;
    //eri_ji[2*jstride+2*kstride] = gout74;
    eri_ij[3+2*kstride] = gout75;
    //eri_ji[3*jstride+2*kstride] = gout75;
    eri_ij[4+2*kstride] = gout76;
    //eri_ji[4*jstride+2*kstride] = gout76;
    eri_ij[5+2*kstride] = gout77;
    //eri_ji[5*jstride+2*kstride] = gout77;
    eri_ij[1*jstride+2*kstride] = gout78;
    //eri_ji[1+2*kstride] = gout78;
    eri_ij[1+1*jstride+2*kstride] = gout79;
    //eri_ji[1*jstride+1+2*kstride] = gout79;
    eri_ij[2+1*jstride+2*kstride] = gout80;
    //eri_ji[2*jstride+1+2*kstride] = gout80;
    eri_ij[3+1*jstride+2*kstride] = gout81;
    //eri_ji[3*jstride+1+2*kstride] = gout81;
    eri_ij[4+1*jstride+2*kstride] = gout82;
    //eri_ji[4*jstride+1+2*kstride] = gout82;
    eri_ij[5+1*jstride+2*kstride] = gout83;
    //eri_ji[5*jstride+1+2*kstride] = gout83;
    eri_ij[2*jstride+2*kstride] = gout84;
    //eri_ji[2+2*kstride] = gout84;
    eri_ij[1+2*jstride+2*kstride] = gout85;
    //eri_ji[1*jstride+2+2*kstride] = gout85;
    eri_ij[2+2*jstride+2*kstride] = gout86;
    //eri_ji[2*jstride+2+2*kstride] = gout86;
    eri_ij[3+2*jstride+2*kstride] = gout87;
    //eri_ji[3*jstride+2+2*kstride] = gout87;
    eri_ij[4+2*jstride+2*kstride] = gout88;
    //eri_ji[4*jstride+2+2*kstride] = gout88;
    eri_ij[5+2*jstride+2*kstride] = gout89;
    //eri_ji[5*jstride+2+2*kstride] = gout89;
    eri_ij[3*jstride+2*kstride] = gout90;
    //eri_ji[3+2*kstride] = gout90;
    eri_ij[1+3*jstride+2*kstride] = gout91;
    //eri_ji[1*jstride+3+2*kstride] = gout91;
    eri_ij[2+3*jstride+2*kstride] = gout92;
    //eri_ji[2*jstride+3+2*kstride] = gout92;
    eri_ij[3+3*jstride+2*kstride] = gout93;
    //eri_ji[3*jstride+3+2*kstride] = gout93;
    eri_ij[4+3*jstride+2*kstride] = gout94;
    //eri_ji[4*jstride+3+2*kstride] = gout94;
    eri_ij[5+3*jstride+2*kstride] = gout95;
    //eri_ji[5*jstride+3+2*kstride] = gout95;
    eri_ij[4*jstride+2*kstride] = gout96;
    //eri_ji[4+2*kstride] = gout96;
    eri_ij[1+4*jstride+2*kstride] = gout97;
    //eri_ji[1*jstride+4+2*kstride] = gout97;
    eri_ij[2+4*jstride+2*kstride] = gout98;
    //eri_ji[2*jstride+4+2*kstride] = gout98;
    eri_ij[3+4*jstride+2*kstride] = gout99;
    //eri_ji[3*jstride+4+2*kstride] = gout99;
    eri_ij[4+4*jstride+2*kstride] = gout100;
    //eri_ji[4*jstride+4+2*kstride] = gout100;
    eri_ij[5+4*jstride+2*kstride] = gout101;
    //eri_ji[5*jstride+4+2*kstride] = gout101;
    eri_ij[5*jstride+2*kstride] = gout102;
    //eri_ji[5+2*kstride] = gout102;
    eri_ij[1+5*jstride+2*kstride] = gout103;
    //eri_ji[1*jstride+5+2*kstride] = gout103;
    eri_ij[2+5*jstride+2*kstride] = gout104;
    //eri_ji[2*jstride+5+2*kstride] = gout104;
    eri_ij[3+5*jstride+2*kstride] = gout105;
    //eri_ji[3*jstride+5+2*kstride] = gout105;
    eri_ij[4+5*jstride+2*kstride] = gout106;
    //eri_ji[4*jstride+5+2*kstride] = gout106;
    eri_ij[5+5*jstride+2*kstride] = gout107;
    //eri_ji[5*jstride+5+2*kstride] = gout107;
}

__global__
static void GINTfill_int2e_kernel3010(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double b10 = b00 + tmp4 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c00x * c00x + b10;
            double g_3 = c00x * (2 * b10 + g_2);
            double g_4 = c0px;
            double g_5 = c0px * c00x + b00;
            double g_6 = b00 * c00x + b10 * c0px + c00x * g_5;
            double g_7 = 2 * b10 * g_5 + b00 * g_2 + c00x * g_6;
            double g_8 = 1;
            double g_9 = c00y;
            double g_10 = c00y * c00y + b10;
            double g_11 = c00y * (2 * b10 + g_10);
            double g_12 = c0py;
            double g_13 = c0py * c00y + b00;
            double g_14 = b00 * c00y + b10 * c0py + c00y * g_13;
            double g_15 = 2 * b10 * g_13 + b00 * g_10 + c00y * g_14;
            double g_16 = weight0 * fac;
            double g_17 = c00z * g_16;
            double g_18 = b10 * g_16 + c00z * g_17;
            double g_19 = 2 * b10 * g_17 + c00z * g_18;
            double g_20 = c0pz * g_16;
            double g_21 = b00 * g_16 + c0pz * g_17;
            double g_22 = b00 * g_17 + b10 * g_20 + c00z * g_21;
            double g_23 = 2 * b10 * g_21 + b00 * g_18 + c00z * g_22;
            gout0 += g_7 * g_8 * g_16;
            gout1 += g_6 * g_9 * g_16;
            gout2 += g_6 * g_8 * g_17;
            gout3 += g_5 * g_10 * g_16;
            gout4 += g_5 * g_9 * g_17;
            gout5 += g_5 * g_8 * g_18;
            gout6 += g_4 * g_11 * g_16;
            gout7 += g_4 * g_10 * g_17;
            gout8 += g_4 * g_9 * g_18;
            gout9 += g_4 * g_8 * g_19;
            gout10 += g_3 * g_12 * g_16;
            gout11 += g_2 * g_13 * g_16;
            gout12 += g_2 * g_12 * g_17;
            gout13 += g_1 * g_14 * g_16;
            gout14 += g_1 * g_13 * g_17;
            gout15 += g_1 * g_12 * g_18;
            gout16 += g_0 * g_15 * g_16;
            gout17 += g_0 * g_14 * g_17;
            gout18 += g_0 * g_13 * g_18;
            gout19 += g_0 * g_12 * g_19;
            gout20 += g_3 * g_8 * g_20;
            gout21 += g_2 * g_9 * g_20;
            gout22 += g_2 * g_8 * g_21;
            gout23 += g_1 * g_10 * g_20;
            gout24 += g_1 * g_9 * g_21;
            gout25 += g_1 * g_8 * g_22;
            gout26 += g_0 * g_11 * g_20;
            gout27 += g_0 * g_10 * g_21;
            gout28 += g_0 * g_9 * g_22;
            gout29 += g_0 * g_8 * g_23;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[3] = gout3;
    //eri_ji[3*jstride] = gout3;
    eri_ij[4] = gout4;
    //eri_ji[4*jstride] = gout4;
    eri_ij[5] = gout5;
    //eri_ji[5*jstride] = gout5;
    eri_ij[6] = gout6;
    //eri_ji[6*jstride] = gout6;
    eri_ij[7] = gout7;
    //eri_ji[7*jstride] = gout7;
    eri_ij[8] = gout8;
    //eri_ji[8*jstride] = gout8;
    eri_ij[9] = gout9;
    //eri_ji[9*jstride] = gout9;
    eri_ij[1*kstride] = gout10;
    //eri_ji[1*kstride] = gout10;
    eri_ij[1+1*kstride] = gout11;
    //eri_ji[1*jstride+1*kstride] = gout11;
    eri_ij[2+1*kstride] = gout12;
    //eri_ji[2*jstride+1*kstride] = gout12;
    eri_ij[3+1*kstride] = gout13;
    //eri_ji[3*jstride+1*kstride] = gout13;
    eri_ij[4+1*kstride] = gout14;
    //eri_ji[4*jstride+1*kstride] = gout14;
    eri_ij[5+1*kstride] = gout15;
    //eri_ji[5*jstride+1*kstride] = gout15;
    eri_ij[6+1*kstride] = gout16;
    //eri_ji[6*jstride+1*kstride] = gout16;
    eri_ij[7+1*kstride] = gout17;
    //eri_ji[7*jstride+1*kstride] = gout17;
    eri_ij[8+1*kstride] = gout18;
    //eri_ji[8*jstride+1*kstride] = gout18;
    eri_ij[9+1*kstride] = gout19;
    //eri_ji[9*jstride+1*kstride] = gout19;
    eri_ij[2*kstride] = gout20;
    //eri_ji[2*kstride] = gout20;
    eri_ij[1+2*kstride] = gout21;
    //eri_ji[1*jstride+2*kstride] = gout21;
    eri_ij[2+2*kstride] = gout22;
    //eri_ji[2*jstride+2*kstride] = gout22;
    eri_ij[3+2*kstride] = gout23;
    //eri_ji[3*jstride+2*kstride] = gout23;
    eri_ij[4+2*kstride] = gout24;
    //eri_ji[4*jstride+2*kstride] = gout24;
    eri_ij[5+2*kstride] = gout25;
    //eri_ji[5*jstride+2*kstride] = gout25;
    eri_ij[6+2*kstride] = gout26;
    //eri_ji[6*jstride+2*kstride] = gout26;
    eri_ij[7+2*kstride] = gout27;
    //eri_ji[7*jstride+2*kstride] = gout27;
    eri_ij[8+2*kstride] = gout28;
    //eri_ji[8*jstride+2*kstride] = gout28;
    eri_ij[9+2*kstride] = gout29;
    //eri_ji[9*jstride+2*kstride] = gout29;
}

__global__
static void GINTfill_int2e_kernel3011(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double gout36 = 0;
    double gout37 = 0;
    double gout38 = 0;
    double gout39 = 0;
    double gout40 = 0;
    double gout41 = 0;
    double gout42 = 0;
    double gout43 = 0;
    double gout44 = 0;
    double gout45 = 0;
    double gout46 = 0;
    double gout47 = 0;
    double gout48 = 0;
    double gout49 = 0;
    double gout50 = 0;
    double gout51 = 0;
    double gout52 = 0;
    double gout53 = 0;
    double gout54 = 0;
    double gout55 = 0;
    double gout56 = 0;
    double gout57 = 0;
    double gout58 = 0;
    double gout59 = 0;
    double gout60 = 0;
    double gout61 = 0;
    double gout62 = 0;
    double gout63 = 0;
    double gout64 = 0;
    double gout65 = 0;
    double gout66 = 0;
    double gout67 = 0;
    double gout68 = 0;
    double gout69 = 0;
    double gout70 = 0;
    double gout71 = 0;
    double gout72 = 0;
    double gout73 = 0;
    double gout74 = 0;
    double gout75 = 0;
    double gout76 = 0;
    double gout77 = 0;
    double gout78 = 0;
    double gout79 = 0;
    double gout80 = 0;
    double gout81 = 0;
    double gout82 = 0;
    double gout83 = 0;
    double gout84 = 0;
    double gout85 = 0;
    double gout86 = 0;
    double gout87 = 0;
    double gout88 = 0;
    double gout89 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    double xkxl = xk - bas_x[lsh];
    double ykyl = yk - bas_y[lsh];
    double zkzl = zk - bas_z[lsh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double b10 = b00 + tmp4 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double b01 = b00 + tmp4 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c00x * c00x + b10;
            double g_3 = c00x * (2 * b10 + g_2);
            double g_4 = c0px;
            double g_5 = c0px * c00x + b00;
            double g_6 = b00 * c00x + b10 * c0px + c00x * g_5;
            double g_7 = 2 * b10 * g_5 + b00 * g_2 + c00x * g_6;
            double g_8 = c0px + xkxl;
            double g_9 = c00x * (c0px + xkxl) + b00;
            double g_10 = b00 * c00x + b10 * c0px + c00x * g_5 + xkxl * g_2;
            double g_11 = 2 * b10 * g_5 + b00 * g_2 + c00x * g_6 + xkxl * g_3;
            double g_12 = c0px * (c0px + xkxl) + b01;
            double g_13 = b00 * c0px + b01 * c00x + c0px * g_5 + xkxl * g_5;
            double g_14 = xkxl * g_6 + c00x * (c0px * g_5 + b01 * c00x + b00 * c0px) + b10 * (c0px * c0px + b01) + 2 * b00 * g_5;
            double g_15 = xkxl * g_7 + c00x * (c00x * (c0px * g_5 + b01 * c00x + b00 * c0px) + b10 * (c0px * c0px + b01) + 2 * b00 * g_5) + 2 * b10*(c0px * g_5 + b01 * c00x + b00 * c0px) + 2 * b00 * g_6;
            double g_16 = 1;
            double g_17 = c00y;
            double g_18 = c00y * c00y + b10;
            double g_19 = c00y * (2 * b10 + g_18);
            double g_20 = c0py;
            double g_21 = c0py * c00y + b00;
            double g_22 = b00 * c00y + b10 * c0py + c00y * g_21;
            double g_23 = 2 * b10 * g_21 + b00 * g_18 + c00y * g_22;
            double g_24 = c0py + ykyl;
            double g_25 = c00y * (c0py + ykyl) + b00;
            double g_26 = b00 * c00y + b10 * c0py + c00y * g_21 + ykyl * g_18;
            double g_27 = 2 * b10 * g_21 + b00 * g_18 + c00y * g_22 + ykyl * g_19;
            double g_28 = c0py * (c0py + ykyl) + b01;
            double g_29 = b00 * c0py + b01 * c00y + c0py * g_21 + ykyl * g_21;
            double g_30 = ykyl * g_22 + c00y * (c0py * g_21 + b01 * c00y + b00 * c0py) + b10 * (c0py * c0py + b01) + 2 * b00 * g_21;
            double g_31 = ykyl * g_23 + c00y * (c00y * (c0py * g_21 + b01 * c00y + b00 * c0py) + b10 * (c0py * c0py + b01) + 2 * b00 * g_21) + 2 * b10*(c0py * g_21 + b01 * c00y + b00 * c0py) + 2 * b00 * g_22;
            double g_32 = weight0 * fac;
            double g_33 = c00z * g_32;
            double g_34 = b10 * g_32 + c00z * g_33;
            double g_35 = 2 * b10 * g_33 + c00z * g_34;
            double g_36 = c0pz * g_32;
            double g_37 = b00 * g_32 + c0pz * g_33;
            double g_38 = b00 * g_33 + b10 * g_36 + c00z * g_37;
            double g_39 = 2 * b10 * g_37 + b00 * g_34 + c00z * g_38;
            double g_40 = g_32 * (c0pz + zkzl);
            double g_41 = b00 * g_32 + c0pz * g_33 + zkzl * g_33;
            double g_42 = b00 * g_33 + b10 * g_36 + c00z * g_37 + zkzl * g_34;
            double g_43 = 2 * b10 * g_37 + b00 * g_34 + c00z * g_38 + zkzl * g_35;
            double g_44 = b01 * g_32 + c0pz * g_36 + zkzl * g_36;
            double g_45 = b00 * g_36 + b01 * g_33 + c0pz * g_37 + zkzl * g_37;
            double g_46 = zkzl * g_38 + c00z * (c0pz * g_37 + b01 * g_33 + b00 * g_36) + b10 * (c0pz * g_36 + b01 * g_32) + 2 * b00 * g_37;
            double g_47 = zkzl * g_39 + c00z * (c00z * (c0pz * g_37 + b01 * g_33 + b00 * g_36) + b10 * (c0pz * g_36 + b01 * g_32) + 2 * b00 * g_37) + 2 * b10*(c0pz * g_37 + b01 * g_33 + b00 * g_36) + 2 * b00 * g_38;
            gout0 += g_15 * g_16 * g_32;
            gout1 += g_14 * g_17 * g_32;
            gout2 += g_14 * g_16 * g_33;
            gout3 += g_13 * g_18 * g_32;
            gout4 += g_13 * g_17 * g_33;
            gout5 += g_13 * g_16 * g_34;
            gout6 += g_12 * g_19 * g_32;
            gout7 += g_12 * g_18 * g_33;
            gout8 += g_12 * g_17 * g_34;
            gout9 += g_12 * g_16 * g_35;
            gout10 += g_11 * g_20 * g_32;
            gout11 += g_10 * g_21 * g_32;
            gout12 += g_10 * g_20 * g_33;
            gout13 += g_9 * g_22 * g_32;
            gout14 += g_9 * g_21 * g_33;
            gout15 += g_9 * g_20 * g_34;
            gout16 += g_8 * g_23 * g_32;
            gout17 += g_8 * g_22 * g_33;
            gout18 += g_8 * g_21 * g_34;
            gout19 += g_8 * g_20 * g_35;
            gout20 += g_11 * g_16 * g_36;
            gout21 += g_10 * g_17 * g_36;
            gout22 += g_10 * g_16 * g_37;
            gout23 += g_9 * g_18 * g_36;
            gout24 += g_9 * g_17 * g_37;
            gout25 += g_9 * g_16 * g_38;
            gout26 += g_8 * g_19 * g_36;
            gout27 += g_8 * g_18 * g_37;
            gout28 += g_8 * g_17 * g_38;
            gout29 += g_8 * g_16 * g_39;
            gout30 += g_7 * g_24 * g_32;
            gout31 += g_6 * g_25 * g_32;
            gout32 += g_6 * g_24 * g_33;
            gout33 += g_5 * g_26 * g_32;
            gout34 += g_5 * g_25 * g_33;
            gout35 += g_5 * g_24 * g_34;
            gout36 += g_4 * g_27 * g_32;
            gout37 += g_4 * g_26 * g_33;
            gout38 += g_4 * g_25 * g_34;
            gout39 += g_4 * g_24 * g_35;
            gout40 += g_3 * g_28 * g_32;
            gout41 += g_2 * g_29 * g_32;
            gout42 += g_2 * g_28 * g_33;
            gout43 += g_1 * g_30 * g_32;
            gout44 += g_1 * g_29 * g_33;
            gout45 += g_1 * g_28 * g_34;
            gout46 += g_0 * g_31 * g_32;
            gout47 += g_0 * g_30 * g_33;
            gout48 += g_0 * g_29 * g_34;
            gout49 += g_0 * g_28 * g_35;
            gout50 += g_3 * g_24 * g_36;
            gout51 += g_2 * g_25 * g_36;
            gout52 += g_2 * g_24 * g_37;
            gout53 += g_1 * g_26 * g_36;
            gout54 += g_1 * g_25 * g_37;
            gout55 += g_1 * g_24 * g_38;
            gout56 += g_0 * g_27 * g_36;
            gout57 += g_0 * g_26 * g_37;
            gout58 += g_0 * g_25 * g_38;
            gout59 += g_0 * g_24 * g_39;
            gout60 += g_7 * g_16 * g_40;
            gout61 += g_6 * g_17 * g_40;
            gout62 += g_6 * g_16 * g_41;
            gout63 += g_5 * g_18 * g_40;
            gout64 += g_5 * g_17 * g_41;
            gout65 += g_5 * g_16 * g_42;
            gout66 += g_4 * g_19 * g_40;
            gout67 += g_4 * g_18 * g_41;
            gout68 += g_4 * g_17 * g_42;
            gout69 += g_4 * g_16 * g_43;
            gout70 += g_3 * g_20 * g_40;
            gout71 += g_2 * g_21 * g_40;
            gout72 += g_2 * g_20 * g_41;
            gout73 += g_1 * g_22 * g_40;
            gout74 += g_1 * g_21 * g_41;
            gout75 += g_1 * g_20 * g_42;
            gout76 += g_0 * g_23 * g_40;
            gout77 += g_0 * g_22 * g_41;
            gout78 += g_0 * g_21 * g_42;
            gout79 += g_0 * g_20 * g_43;
            gout80 += g_3 * g_16 * g_44;
            gout81 += g_2 * g_17 * g_44;
            gout82 += g_2 * g_16 * g_45;
            gout83 += g_1 * g_18 * g_44;
            gout84 += g_1 * g_17 * g_45;
            gout85 += g_1 * g_16 * g_46;
            gout86 += g_0 * g_19 * g_44;
            gout87 += g_0 * g_18 * g_45;
            gout88 += g_0 * g_17 * g_46;
            gout89 += g_0 * g_16 * g_47;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[3] = gout3;
    //eri_ji[3*jstride] = gout3;
    eri_ij[4] = gout4;
    //eri_ji[4*jstride] = gout4;
    eri_ij[5] = gout5;
    //eri_ji[5*jstride] = gout5;
    eri_ij[6] = gout6;
    //eri_ji[6*jstride] = gout6;
    eri_ij[7] = gout7;
    //eri_ji[7*jstride] = gout7;
    eri_ij[8] = gout8;
    //eri_ji[8*jstride] = gout8;
    eri_ij[9] = gout9;
    //eri_ji[9*jstride] = gout9;
    eri_ij[1*kstride] = gout10;
    //eri_ji[1*kstride] = gout10;
    eri_ij[1+1*kstride] = gout11;
    //eri_ji[1*jstride+1*kstride] = gout11;
    eri_ij[2+1*kstride] = gout12;
    //eri_ji[2*jstride+1*kstride] = gout12;
    eri_ij[3+1*kstride] = gout13;
    //eri_ji[3*jstride+1*kstride] = gout13;
    eri_ij[4+1*kstride] = gout14;
    //eri_ji[4*jstride+1*kstride] = gout14;
    eri_ij[5+1*kstride] = gout15;
    //eri_ji[5*jstride+1*kstride] = gout15;
    eri_ij[6+1*kstride] = gout16;
    //eri_ji[6*jstride+1*kstride] = gout16;
    eri_ij[7+1*kstride] = gout17;
    //eri_ji[7*jstride+1*kstride] = gout17;
    eri_ij[8+1*kstride] = gout18;
    //eri_ji[8*jstride+1*kstride] = gout18;
    eri_ij[9+1*kstride] = gout19;
    //eri_ji[9*jstride+1*kstride] = gout19;
    eri_ij[2*kstride] = gout20;
    //eri_ji[2*kstride] = gout20;
    eri_ij[1+2*kstride] = gout21;
    //eri_ji[1*jstride+2*kstride] = gout21;
    eri_ij[2+2*kstride] = gout22;
    //eri_ji[2*jstride+2*kstride] = gout22;
    eri_ij[3+2*kstride] = gout23;
    //eri_ji[3*jstride+2*kstride] = gout23;
    eri_ij[4+2*kstride] = gout24;
    //eri_ji[4*jstride+2*kstride] = gout24;
    eri_ij[5+2*kstride] = gout25;
    //eri_ji[5*jstride+2*kstride] = gout25;
    eri_ij[6+2*kstride] = gout26;
    //eri_ji[6*jstride+2*kstride] = gout26;
    eri_ij[7+2*kstride] = gout27;
    //eri_ji[7*jstride+2*kstride] = gout27;
    eri_ij[8+2*kstride] = gout28;
    //eri_ji[8*jstride+2*kstride] = gout28;
    eri_ij[9+2*kstride] = gout29;
    //eri_ji[9*jstride+2*kstride] = gout29;
    eri_ij[1*lstride] = gout30;
    //eri_ji[1*lstride] = gout30;
    eri_ij[1+1*lstride] = gout31;
    //eri_ji[1*jstride+1*lstride] = gout31;
    eri_ij[2+1*lstride] = gout32;
    //eri_ji[2*jstride+1*lstride] = gout32;
    eri_ij[3+1*lstride] = gout33;
    //eri_ji[3*jstride+1*lstride] = gout33;
    eri_ij[4+1*lstride] = gout34;
    //eri_ji[4*jstride+1*lstride] = gout34;
    eri_ij[5+1*lstride] = gout35;
    //eri_ji[5*jstride+1*lstride] = gout35;
    eri_ij[6+1*lstride] = gout36;
    //eri_ji[6*jstride+1*lstride] = gout36;
    eri_ij[7+1*lstride] = gout37;
    //eri_ji[7*jstride+1*lstride] = gout37;
    eri_ij[8+1*lstride] = gout38;
    //eri_ji[8*jstride+1*lstride] = gout38;
    eri_ij[9+1*lstride] = gout39;
    //eri_ji[9*jstride+1*lstride] = gout39;
    eri_ij[1*kstride+1*lstride] = gout40;
    //eri_ji[1*kstride+1*lstride] = gout40;
    eri_ij[1+1*kstride+1*lstride] = gout41;
    //eri_ji[1*jstride+1*kstride+1*lstride] = gout41;
    eri_ij[2+1*kstride+1*lstride] = gout42;
    //eri_ji[2*jstride+1*kstride+1*lstride] = gout42;
    eri_ij[3+1*kstride+1*lstride] = gout43;
    //eri_ji[3*jstride+1*kstride+1*lstride] = gout43;
    eri_ij[4+1*kstride+1*lstride] = gout44;
    //eri_ji[4*jstride+1*kstride+1*lstride] = gout44;
    eri_ij[5+1*kstride+1*lstride] = gout45;
    //eri_ji[5*jstride+1*kstride+1*lstride] = gout45;
    eri_ij[6+1*kstride+1*lstride] = gout46;
    //eri_ji[6*jstride+1*kstride+1*lstride] = gout46;
    eri_ij[7+1*kstride+1*lstride] = gout47;
    //eri_ji[7*jstride+1*kstride+1*lstride] = gout47;
    eri_ij[8+1*kstride+1*lstride] = gout48;
    //eri_ji[8*jstride+1*kstride+1*lstride] = gout48;
    eri_ij[9+1*kstride+1*lstride] = gout49;
    //eri_ji[9*jstride+1*kstride+1*lstride] = gout49;
    eri_ij[2*kstride+1*lstride] = gout50;
    //eri_ji[2*kstride+1*lstride] = gout50;
    eri_ij[1+2*kstride+1*lstride] = gout51;
    //eri_ji[1*jstride+2*kstride+1*lstride] = gout51;
    eri_ij[2+2*kstride+1*lstride] = gout52;
    //eri_ji[2*jstride+2*kstride+1*lstride] = gout52;
    eri_ij[3+2*kstride+1*lstride] = gout53;
    //eri_ji[3*jstride+2*kstride+1*lstride] = gout53;
    eri_ij[4+2*kstride+1*lstride] = gout54;
    //eri_ji[4*jstride+2*kstride+1*lstride] = gout54;
    eri_ij[5+2*kstride+1*lstride] = gout55;
    //eri_ji[5*jstride+2*kstride+1*lstride] = gout55;
    eri_ij[6+2*kstride+1*lstride] = gout56;
    //eri_ji[6*jstride+2*kstride+1*lstride] = gout56;
    eri_ij[7+2*kstride+1*lstride] = gout57;
    //eri_ji[7*jstride+2*kstride+1*lstride] = gout57;
    eri_ij[8+2*kstride+1*lstride] = gout58;
    //eri_ji[8*jstride+2*kstride+1*lstride] = gout58;
    eri_ij[9+2*kstride+1*lstride] = gout59;
    //eri_ji[9*jstride+2*kstride+1*lstride] = gout59;
    eri_ij[2*lstride] = gout60;
    //eri_ji[2*lstride] = gout60;
    eri_ij[1+2*lstride] = gout61;
    //eri_ji[1*jstride+2*lstride] = gout61;
    eri_ij[2+2*lstride] = gout62;
    //eri_ji[2*jstride+2*lstride] = gout62;
    eri_ij[3+2*lstride] = gout63;
    //eri_ji[3*jstride+2*lstride] = gout63;
    eri_ij[4+2*lstride] = gout64;
    //eri_ji[4*jstride+2*lstride] = gout64;
    eri_ij[5+2*lstride] = gout65;
    //eri_ji[5*jstride+2*lstride] = gout65;
    eri_ij[6+2*lstride] = gout66;
    //eri_ji[6*jstride+2*lstride] = gout66;
    eri_ij[7+2*lstride] = gout67;
    //eri_ji[7*jstride+2*lstride] = gout67;
    eri_ij[8+2*lstride] = gout68;
    //eri_ji[8*jstride+2*lstride] = gout68;
    eri_ij[9+2*lstride] = gout69;
    //eri_ji[9*jstride+2*lstride] = gout69;
    eri_ij[1*kstride+2*lstride] = gout70;
    //eri_ji[1*kstride+2*lstride] = gout70;
    eri_ij[1+1*kstride+2*lstride] = gout71;
    //eri_ji[1*jstride+1*kstride+2*lstride] = gout71;
    eri_ij[2+1*kstride+2*lstride] = gout72;
    //eri_ji[2*jstride+1*kstride+2*lstride] = gout72;
    eri_ij[3+1*kstride+2*lstride] = gout73;
    //eri_ji[3*jstride+1*kstride+2*lstride] = gout73;
    eri_ij[4+1*kstride+2*lstride] = gout74;
    //eri_ji[4*jstride+1*kstride+2*lstride] = gout74;
    eri_ij[5+1*kstride+2*lstride] = gout75;
    //eri_ji[5*jstride+1*kstride+2*lstride] = gout75;
    eri_ij[6+1*kstride+2*lstride] = gout76;
    //eri_ji[6*jstride+1*kstride+2*lstride] = gout76;
    eri_ij[7+1*kstride+2*lstride] = gout77;
    //eri_ji[7*jstride+1*kstride+2*lstride] = gout77;
    eri_ij[8+1*kstride+2*lstride] = gout78;
    //eri_ji[8*jstride+1*kstride+2*lstride] = gout78;
    eri_ij[9+1*kstride+2*lstride] = gout79;
    //eri_ji[9*jstride+1*kstride+2*lstride] = gout79;
    eri_ij[2*kstride+2*lstride] = gout80;
    //eri_ji[2*kstride+2*lstride] = gout80;
    eri_ij[1+2*kstride+2*lstride] = gout81;
    //eri_ji[1*jstride+2*kstride+2*lstride] = gout81;
    eri_ij[2+2*kstride+2*lstride] = gout82;
    //eri_ji[2*jstride+2*kstride+2*lstride] = gout82;
    eri_ij[3+2*kstride+2*lstride] = gout83;
    //eri_ji[3*jstride+2*kstride+2*lstride] = gout83;
    eri_ij[4+2*kstride+2*lstride] = gout84;
    //eri_ji[4*jstride+2*kstride+2*lstride] = gout84;
    eri_ij[5+2*kstride+2*lstride] = gout85;
    //eri_ji[5*jstride+2*kstride+2*lstride] = gout85;
    eri_ij[6+2*kstride+2*lstride] = gout86;
    //eri_ji[6*jstride+2*kstride+2*lstride] = gout86;
    eri_ij[7+2*kstride+2*lstride] = gout87;
    //eri_ji[7*jstride+2*kstride+2*lstride] = gout87;
    eri_ij[8+2*kstride+2*lstride] = gout88;
    //eri_ji[8*jstride+2*kstride+2*lstride] = gout88;
    eri_ij[9+2*kstride+2*lstride] = gout89;
    //eri_ji[9*jstride+2*kstride+2*lstride] = gout89;
}

__global__
static void GINTfill_int2e_kernel3020(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double gout36 = 0;
    double gout37 = 0;
    double gout38 = 0;
    double gout39 = 0;
    double gout40 = 0;
    double gout41 = 0;
    double gout42 = 0;
    double gout43 = 0;
    double gout44 = 0;
    double gout45 = 0;
    double gout46 = 0;
    double gout47 = 0;
    double gout48 = 0;
    double gout49 = 0;
    double gout50 = 0;
    double gout51 = 0;
    double gout52 = 0;
    double gout53 = 0;
    double gout54 = 0;
    double gout55 = 0;
    double gout56 = 0;
    double gout57 = 0;
    double gout58 = 0;
    double gout59 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double b10 = b00 + tmp4 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double b01 = b00 + tmp4 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c00x * c00x + b10;
            double g_3 = c00x * (2 * b10 + g_2);
            double g_4 = c0px;
            double g_5 = c0px * c00x + b00;
            double g_6 = b00 * c00x + b10 * c0px + c00x * g_5;
            double g_7 = 2 * b10 * g_5 + b00 * g_2 + c00x * g_6;
            double g_8 = c0px * c0px + b01;
            double g_9 = b00 * c0px + b01 * c00x + c0px * g_5;
            double g_10 = 2 * b00 * g_5 + b10 * g_8 + c00x * g_9;
            double g_11 = 2 * (b00 * g_6 + b10 * g_9) + c00x * g_10;
            double g_12 = 1;
            double g_13 = c00y;
            double g_14 = c00y * c00y + b10;
            double g_15 = c00y * (2 * b10 + g_14);
            double g_16 = c0py;
            double g_17 = c0py * c00y + b00;
            double g_18 = b00 * c00y + b10 * c0py + c00y * g_17;
            double g_19 = 2 * b10 * g_17 + b00 * g_14 + c00y * g_18;
            double g_20 = c0py * c0py + b01;
            double g_21 = b00 * c0py + b01 * c00y + c0py * g_17;
            double g_22 = 2 * b00 * g_17 + b10 * g_20 + c00y * g_21;
            double g_23 = 2 * (b00 * g_18 + b10 * g_21) + c00y * g_22;
            double g_24 = weight0 * fac;
            double g_25 = c00z * g_24;
            double g_26 = b10 * g_24 + c00z * g_25;
            double g_27 = 2 * b10 * g_25 + c00z * g_26;
            double g_28 = c0pz * g_24;
            double g_29 = b00 * g_24 + c0pz * g_25;
            double g_30 = b00 * g_25 + b10 * g_28 + c00z * g_29;
            double g_31 = 2 * b10 * g_29 + b00 * g_26 + c00z * g_30;
            double g_32 = b01 * g_24 + c0pz * g_28;
            double g_33 = b00 * g_28 + b01 * g_25 + c0pz * g_29;
            double g_34 = 2 * b00 * g_29 + b10 * g_32 + c00z * g_33;
            double g_35 = 2 * (b00 * g_30 + b10 * g_33) + c00z * g_34;
            gout0 += g_11 * g_12 * g_24;
            gout1 += g_10 * g_13 * g_24;
            gout2 += g_10 * g_12 * g_25;
            gout3 += g_9 * g_14 * g_24;
            gout4 += g_9 * g_13 * g_25;
            gout5 += g_9 * g_12 * g_26;
            gout6 += g_8 * g_15 * g_24;
            gout7 += g_8 * g_14 * g_25;
            gout8 += g_8 * g_13 * g_26;
            gout9 += g_8 * g_12 * g_27;
            gout10 += g_7 * g_16 * g_24;
            gout11 += g_6 * g_17 * g_24;
            gout12 += g_6 * g_16 * g_25;
            gout13 += g_5 * g_18 * g_24;
            gout14 += g_5 * g_17 * g_25;
            gout15 += g_5 * g_16 * g_26;
            gout16 += g_4 * g_19 * g_24;
            gout17 += g_4 * g_18 * g_25;
            gout18 += g_4 * g_17 * g_26;
            gout19 += g_4 * g_16 * g_27;
            gout20 += g_7 * g_12 * g_28;
            gout21 += g_6 * g_13 * g_28;
            gout22 += g_6 * g_12 * g_29;
            gout23 += g_5 * g_14 * g_28;
            gout24 += g_5 * g_13 * g_29;
            gout25 += g_5 * g_12 * g_30;
            gout26 += g_4 * g_15 * g_28;
            gout27 += g_4 * g_14 * g_29;
            gout28 += g_4 * g_13 * g_30;
            gout29 += g_4 * g_12 * g_31;
            gout30 += g_3 * g_20 * g_24;
            gout31 += g_2 * g_21 * g_24;
            gout32 += g_2 * g_20 * g_25;
            gout33 += g_1 * g_22 * g_24;
            gout34 += g_1 * g_21 * g_25;
            gout35 += g_1 * g_20 * g_26;
            gout36 += g_0 * g_23 * g_24;
            gout37 += g_0 * g_22 * g_25;
            gout38 += g_0 * g_21 * g_26;
            gout39 += g_0 * g_20 * g_27;
            gout40 += g_3 * g_16 * g_28;
            gout41 += g_2 * g_17 * g_28;
            gout42 += g_2 * g_16 * g_29;
            gout43 += g_1 * g_18 * g_28;
            gout44 += g_1 * g_17 * g_29;
            gout45 += g_1 * g_16 * g_30;
            gout46 += g_0 * g_19 * g_28;
            gout47 += g_0 * g_18 * g_29;
            gout48 += g_0 * g_17 * g_30;
            gout49 += g_0 * g_16 * g_31;
            gout50 += g_3 * g_12 * g_32;
            gout51 += g_2 * g_13 * g_32;
            gout52 += g_2 * g_12 * g_33;
            gout53 += g_1 * g_14 * g_32;
            gout54 += g_1 * g_13 * g_33;
            gout55 += g_1 * g_12 * g_34;
            gout56 += g_0 * g_15 * g_32;
            gout57 += g_0 * g_14 * g_33;
            gout58 += g_0 * g_13 * g_34;
            gout59 += g_0 * g_12 * g_35;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[3] = gout3;
    //eri_ji[3*jstride] = gout3;
    eri_ij[4] = gout4;
    //eri_ji[4*jstride] = gout4;
    eri_ij[5] = gout5;
    //eri_ji[5*jstride] = gout5;
    eri_ij[6] = gout6;
    //eri_ji[6*jstride] = gout6;
    eri_ij[7] = gout7;
    //eri_ji[7*jstride] = gout7;
    eri_ij[8] = gout8;
    //eri_ji[8*jstride] = gout8;
    eri_ij[9] = gout9;
    //eri_ji[9*jstride] = gout9;
    eri_ij[1*kstride] = gout10;
    //eri_ji[1*kstride] = gout10;
    eri_ij[1+1*kstride] = gout11;
    //eri_ji[1*jstride+1*kstride] = gout11;
    eri_ij[2+1*kstride] = gout12;
    //eri_ji[2*jstride+1*kstride] = gout12;
    eri_ij[3+1*kstride] = gout13;
    //eri_ji[3*jstride+1*kstride] = gout13;
    eri_ij[4+1*kstride] = gout14;
    //eri_ji[4*jstride+1*kstride] = gout14;
    eri_ij[5+1*kstride] = gout15;
    //eri_ji[5*jstride+1*kstride] = gout15;
    eri_ij[6+1*kstride] = gout16;
    //eri_ji[6*jstride+1*kstride] = gout16;
    eri_ij[7+1*kstride] = gout17;
    //eri_ji[7*jstride+1*kstride] = gout17;
    eri_ij[8+1*kstride] = gout18;
    //eri_ji[8*jstride+1*kstride] = gout18;
    eri_ij[9+1*kstride] = gout19;
    //eri_ji[9*jstride+1*kstride] = gout19;
    eri_ij[2*kstride] = gout20;
    //eri_ji[2*kstride] = gout20;
    eri_ij[1+2*kstride] = gout21;
    //eri_ji[1*jstride+2*kstride] = gout21;
    eri_ij[2+2*kstride] = gout22;
    //eri_ji[2*jstride+2*kstride] = gout22;
    eri_ij[3+2*kstride] = gout23;
    //eri_ji[3*jstride+2*kstride] = gout23;
    eri_ij[4+2*kstride] = gout24;
    //eri_ji[4*jstride+2*kstride] = gout24;
    eri_ij[5+2*kstride] = gout25;
    //eri_ji[5*jstride+2*kstride] = gout25;
    eri_ij[6+2*kstride] = gout26;
    //eri_ji[6*jstride+2*kstride] = gout26;
    eri_ij[7+2*kstride] = gout27;
    //eri_ji[7*jstride+2*kstride] = gout27;
    eri_ij[8+2*kstride] = gout28;
    //eri_ji[8*jstride+2*kstride] = gout28;
    eri_ij[9+2*kstride] = gout29;
    //eri_ji[9*jstride+2*kstride] = gout29;
    eri_ij[3*kstride] = gout30;
    //eri_ji[3*kstride] = gout30;
    eri_ij[1+3*kstride] = gout31;
    //eri_ji[1*jstride+3*kstride] = gout31;
    eri_ij[2+3*kstride] = gout32;
    //eri_ji[2*jstride+3*kstride] = gout32;
    eri_ij[3+3*kstride] = gout33;
    //eri_ji[3*jstride+3*kstride] = gout33;
    eri_ij[4+3*kstride] = gout34;
    //eri_ji[4*jstride+3*kstride] = gout34;
    eri_ij[5+3*kstride] = gout35;
    //eri_ji[5*jstride+3*kstride] = gout35;
    eri_ij[6+3*kstride] = gout36;
    //eri_ji[6*jstride+3*kstride] = gout36;
    eri_ij[7+3*kstride] = gout37;
    //eri_ji[7*jstride+3*kstride] = gout37;
    eri_ij[8+3*kstride] = gout38;
    //eri_ji[8*jstride+3*kstride] = gout38;
    eri_ij[9+3*kstride] = gout39;
    //eri_ji[9*jstride+3*kstride] = gout39;
    eri_ij[4*kstride] = gout40;
    //eri_ji[4*kstride] = gout40;
    eri_ij[1+4*kstride] = gout41;
    //eri_ji[1*jstride+4*kstride] = gout41;
    eri_ij[2+4*kstride] = gout42;
    //eri_ji[2*jstride+4*kstride] = gout42;
    eri_ij[3+4*kstride] = gout43;
    //eri_ji[3*jstride+4*kstride] = gout43;
    eri_ij[4+4*kstride] = gout44;
    //eri_ji[4*jstride+4*kstride] = gout44;
    eri_ij[5+4*kstride] = gout45;
    //eri_ji[5*jstride+4*kstride] = gout45;
    eri_ij[6+4*kstride] = gout46;
    //eri_ji[6*jstride+4*kstride] = gout46;
    eri_ij[7+4*kstride] = gout47;
    //eri_ji[7*jstride+4*kstride] = gout47;
    eri_ij[8+4*kstride] = gout48;
    //eri_ji[8*jstride+4*kstride] = gout48;
    eri_ij[9+4*kstride] = gout49;
    //eri_ji[9*jstride+4*kstride] = gout49;
    eri_ij[5*kstride] = gout50;
    //eri_ji[5*kstride] = gout50;
    eri_ij[1+5*kstride] = gout51;
    //eri_ji[1*jstride+5*kstride] = gout51;
    eri_ij[2+5*kstride] = gout52;
    //eri_ji[2*jstride+5*kstride] = gout52;
    eri_ij[3+5*kstride] = gout53;
    //eri_ji[3*jstride+5*kstride] = gout53;
    eri_ij[4+5*kstride] = gout54;
    //eri_ji[4*jstride+5*kstride] = gout54;
    eri_ij[5+5*kstride] = gout55;
    //eri_ji[5*jstride+5*kstride] = gout55;
    eri_ij[6+5*kstride] = gout56;
    //eri_ji[6*jstride+5*kstride] = gout56;
    eri_ij[7+5*kstride] = gout57;
    //eri_ji[7*jstride+5*kstride] = gout57;
    eri_ij[8+5*kstride] = gout58;
    //eri_ji[8*jstride+5*kstride] = gout58;
    eri_ij[9+5*kstride] = gout59;
    //eri_ji[9*jstride+5*kstride] = gout59;
}

__global__
static void GINTfill_int2e_kernel3100(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xixj = xi - bas_x[jsh];
    double yiyj = yi - bas_y[jsh];
    double zizj = zi - bas_z[jsh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double b10 = b00 + tmp4 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c00x * c00x + b10;
            double g_3 = c00x * (2 * b10 + g_2);
            double g_4 = c00x + xixj;
            double g_5 = c00x * (c00x + xixj) + b10;
            double g_6 = c00x * (2 * b10 + g_2) + xixj * g_2;
            double g_7 = 3 * b10 * g_2 + c00x * g_3 + xixj * g_3;
            double g_8 = 1;
            double g_9 = c00y;
            double g_10 = c00y * c00y + b10;
            double g_11 = c00y * (2 * b10 + g_10);
            double g_12 = c00y + yiyj;
            double g_13 = c00y * (c00y + yiyj) + b10;
            double g_14 = c00y * (2 * b10 + g_10) + yiyj * g_10;
            double g_15 = 3 * b10 * g_10 + c00y * g_11 + yiyj * g_11;
            double g_16 = weight0 * fac;
            double g_17 = c00z * g_16;
            double g_18 = b10 * g_16 + c00z * g_17;
            double g_19 = 2 * b10 * g_17 + c00z * g_18;
            double g_20 = g_16 * (c00z + zizj);
            double g_21 = b10 * g_16 + c00z * g_17 + zizj * g_17;
            double g_22 = 2 * b10 * g_17 + c00z * g_18 + zizj * g_18;
            double g_23 = 3 * b10 * g_18 + c00z * g_19 + zizj * g_19;
            gout0 += g_7 * g_8 * g_16;
            gout1 += g_6 * g_9 * g_16;
            gout2 += g_6 * g_8 * g_17;
            gout3 += g_5 * g_10 * g_16;
            gout4 += g_5 * g_9 * g_17;
            gout5 += g_5 * g_8 * g_18;
            gout6 += g_4 * g_11 * g_16;
            gout7 += g_4 * g_10 * g_17;
            gout8 += g_4 * g_9 * g_18;
            gout9 += g_4 * g_8 * g_19;
            gout10 += g_3 * g_12 * g_16;
            gout11 += g_2 * g_13 * g_16;
            gout12 += g_2 * g_12 * g_17;
            gout13 += g_1 * g_14 * g_16;
            gout14 += g_1 * g_13 * g_17;
            gout15 += g_1 * g_12 * g_18;
            gout16 += g_0 * g_15 * g_16;
            gout17 += g_0 * g_14 * g_17;
            gout18 += g_0 * g_13 * g_18;
            gout19 += g_0 * g_12 * g_19;
            gout20 += g_3 * g_8 * g_20;
            gout21 += g_2 * g_9 * g_20;
            gout22 += g_2 * g_8 * g_21;
            gout23 += g_1 * g_10 * g_20;
            gout24 += g_1 * g_9 * g_21;
            gout25 += g_1 * g_8 * g_22;
            gout26 += g_0 * g_11 * g_20;
            gout27 += g_0 * g_10 * g_21;
            gout28 += g_0 * g_9 * g_22;
            gout29 += g_0 * g_8 * g_23;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j; 
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[3] = gout3;
    //eri_ji[3*jstride] = gout3;
    eri_ij[4] = gout4;
    //eri_ji[4*jstride] = gout4;
    eri_ij[5] = gout5;
    //eri_ji[5*jstride] = gout5;
    eri_ij[6] = gout6;
    //eri_ji[6*jstride] = gout6;
    eri_ij[7] = gout7;
    //eri_ji[7*jstride] = gout7;
    eri_ij[8] = gout8;
    //eri_ji[8*jstride] = gout8;
    eri_ij[9] = gout9;
    //eri_ji[9*jstride] = gout9;
    eri_ij[1*jstride] = gout10;
    //eri_ji[1] = gout10;
    eri_ij[1+1*jstride] = gout11;
    //eri_ji[1*jstride+1] = gout11;
    eri_ij[2+1*jstride] = gout12;
    //eri_ji[2*jstride+1] = gout12;
    eri_ij[3+1*jstride] = gout13;
    //eri_ji[3*jstride+1] = gout13;
    eri_ij[4+1*jstride] = gout14;
    //eri_ji[4*jstride+1] = gout14;
    eri_ij[5+1*jstride] = gout15;
    //eri_ji[5*jstride+1] = gout15;
    eri_ij[6+1*jstride] = gout16;
    //eri_ji[6*jstride+1] = gout16;
    eri_ij[7+1*jstride] = gout17;
    //eri_ji[7*jstride+1] = gout17;
    eri_ij[8+1*jstride] = gout18;
    //eri_ji[8*jstride+1] = gout18;
    eri_ij[9+1*jstride] = gout19;
    //eri_ji[9*jstride+1] = gout19;
    eri_ij[2*jstride] = gout20;
    //eri_ji[2] = gout20;
    eri_ij[1+2*jstride] = gout21;
    //eri_ji[1*jstride+2] = gout21;
    eri_ij[2+2*jstride] = gout22;
    //eri_ji[2*jstride+2] = gout22;
    eri_ij[3+2*jstride] = gout23;
    //eri_ji[3*jstride+2] = gout23;
    eri_ij[4+2*jstride] = gout24;
    //eri_ji[4*jstride+2] = gout24;
    eri_ij[5+2*jstride] = gout25;
    //eri_ji[5*jstride+2] = gout25;
    eri_ij[6+2*jstride] = gout26;
    //eri_ji[6*jstride+2] = gout26;
    eri_ij[7+2*jstride] = gout27;
    //eri_ji[7*jstride+2] = gout27;
    eri_ij[8+2*jstride] = gout28;
    //eri_ji[8*jstride+2] = gout28;
    eri_ij[9+2*jstride] = gout29;
    //eri_ji[9*jstride+2] = gout29;
}

__global__
static void GINTfill_int2e_kernel3110(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double gout36 = 0;
    double gout37 = 0;
    double gout38 = 0;
    double gout39 = 0;
    double gout40 = 0;
    double gout41 = 0;
    double gout42 = 0;
    double gout43 = 0;
    double gout44 = 0;
    double gout45 = 0;
    double gout46 = 0;
    double gout47 = 0;
    double gout48 = 0;
    double gout49 = 0;
    double gout50 = 0;
    double gout51 = 0;
    double gout52 = 0;
    double gout53 = 0;
    double gout54 = 0;
    double gout55 = 0;
    double gout56 = 0;
    double gout57 = 0;
    double gout58 = 0;
    double gout59 = 0;
    double gout60 = 0;
    double gout61 = 0;
    double gout62 = 0;
    double gout63 = 0;
    double gout64 = 0;
    double gout65 = 0;
    double gout66 = 0;
    double gout67 = 0;
    double gout68 = 0;
    double gout69 = 0;
    double gout70 = 0;
    double gout71 = 0;
    double gout72 = 0;
    double gout73 = 0;
    double gout74 = 0;
    double gout75 = 0;
    double gout76 = 0;
    double gout77 = 0;
    double gout78 = 0;
    double gout79 = 0;
    double gout80 = 0;
    double gout81 = 0;
    double gout82 = 0;
    double gout83 = 0;
    double gout84 = 0;
    double gout85 = 0;
    double gout86 = 0;
    double gout87 = 0;
    double gout88 = 0;
    double gout89 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xixj = xi - bas_x[jsh];
    double yiyj = yi - bas_y[jsh];
    double zizj = zi - bas_z[jsh];
    double xk = bas_x[ksh];
    double yk = bas_y[ksh];
    double zk = bas_z[ksh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double b10 = b00 + tmp4 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double tmp3 = tmp1 * aij;
            double c0px = xkl - xk + tmp3 * xijxkl;
            double c0py = ykl - yk + tmp3 * yijykl;
            double c0pz = zkl - zk + tmp3 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c00x * c00x + b10;
            double g_3 = c00x * (2 * b10 + g_2);
            double g_4 = c00x + xixj;
            double g_5 = c00x * (c00x + xixj) + b10;
            double g_6 = c00x * (2 * b10 + g_2) + xixj * g_2;
            double g_7 = 3 * b10 * g_2 + c00x * g_3 + xixj * g_3;
            double g_8 = c0px;
            double g_9 = c0px * c00x + b00;
            double g_10 = b00 * c00x + b10 * c0px + c00x * g_9;
            double g_11 = 2 * b10 * g_9 + b00 * g_2 + c00x * g_10;
            double g_12 = c0px * (c00x + xixj) + b00;
            double g_13 = b00 * c00x + b10 * c0px + c00x * g_9 + xixj * g_9;
            double g_14 = 2 * b10 * g_9 + b00 * g_2 + c00x * g_10 + xixj * g_10;
            double g_15 = 3 * b10 * g_10 + b00 * g_3 + c00x * g_11 + xixj * g_11;
            double g_16 = 1;
            double g_17 = c00y;
            double g_18 = c00y * c00y + b10;
            double g_19 = c00y * (2 * b10 + g_18);
            double g_20 = c00y + yiyj;
            double g_21 = c00y * (c00y + yiyj) + b10;
            double g_22 = c00y * (2 * b10 + g_18) + yiyj * g_18;
            double g_23 = 3 * b10 * g_18 + c00y * g_19 + yiyj * g_19;
            double g_24 = c0py;
            double g_25 = c0py * c00y + b00;
            double g_26 = b00 * c00y + b10 * c0py + c00y * g_25;
            double g_27 = 2 * b10 * g_25 + b00 * g_18 + c00y * g_26;
            double g_28 = c0py * (c00y + yiyj) + b00;
            double g_29 = b00 * c00y + b10 * c0py + c00y * g_25 + yiyj * g_25;
            double g_30 = 2 * b10 * g_25 + b00 * g_18 + c00y * g_26 + yiyj * g_26;
            double g_31 = 3 * b10 * g_26 + b00 * g_19 + c00y * g_27 + yiyj * g_27;
            double g_32 = weight0 * fac;
            double g_33 = c00z * g_32;
            double g_34 = b10 * g_32 + c00z * g_33;
            double g_35 = 2 * b10 * g_33 + c00z * g_34;
            double g_36 = g_32 * (c00z + zizj);
            double g_37 = b10 * g_32 + c00z * g_33 + zizj * g_33;
            double g_38 = 2 * b10 * g_33 + c00z * g_34 + zizj * g_34;
            double g_39 = 3 * b10 * g_34 + c00z * g_35 + zizj * g_35;
            double g_40 = c0pz * g_32;
            double g_41 = b00 * g_32 + c0pz * g_33;
            double g_42 = b00 * g_33 + b10 * g_40 + c00z * g_41;
            double g_43 = 2 * b10 * g_41 + b00 * g_34 + c00z * g_42;
            double g_44 = b00 * g_32 + c0pz * g_33 + zizj * g_40;
            double g_45 = b00 * g_33 + b10 * g_40 + c00z * g_41 + zizj * g_41;
            double g_46 = 2 * b10 * g_41 + b00 * g_34 + c00z * g_42 + zizj * g_42;
            double g_47 = 3 * b10 * g_42 + b00 * g_35 + c00z * g_43 + zizj * g_43;
            gout0 += g_15 * g_16 * g_32;
            gout1 += g_14 * g_17 * g_32;
            gout2 += g_14 * g_16 * g_33;
            gout3 += g_13 * g_18 * g_32;
            gout4 += g_13 * g_17 * g_33;
            gout5 += g_13 * g_16 * g_34;
            gout6 += g_12 * g_19 * g_32;
            gout7 += g_12 * g_18 * g_33;
            gout8 += g_12 * g_17 * g_34;
            gout9 += g_12 * g_16 * g_35;
            gout10 += g_11 * g_20 * g_32;
            gout11 += g_10 * g_21 * g_32;
            gout12 += g_10 * g_20 * g_33;
            gout13 += g_9 * g_22 * g_32;
            gout14 += g_9 * g_21 * g_33;
            gout15 += g_9 * g_20 * g_34;
            gout16 += g_8 * g_23 * g_32;
            gout17 += g_8 * g_22 * g_33;
            gout18 += g_8 * g_21 * g_34;
            gout19 += g_8 * g_20 * g_35;
            gout20 += g_11 * g_16 * g_36;
            gout21 += g_10 * g_17 * g_36;
            gout22 += g_10 * g_16 * g_37;
            gout23 += g_9 * g_18 * g_36;
            gout24 += g_9 * g_17 * g_37;
            gout25 += g_9 * g_16 * g_38;
            gout26 += g_8 * g_19 * g_36;
            gout27 += g_8 * g_18 * g_37;
            gout28 += g_8 * g_17 * g_38;
            gout29 += g_8 * g_16 * g_39;
            gout30 += g_7 * g_24 * g_32;
            gout31 += g_6 * g_25 * g_32;
            gout32 += g_6 * g_24 * g_33;
            gout33 += g_5 * g_26 * g_32;
            gout34 += g_5 * g_25 * g_33;
            gout35 += g_5 * g_24 * g_34;
            gout36 += g_4 * g_27 * g_32;
            gout37 += g_4 * g_26 * g_33;
            gout38 += g_4 * g_25 * g_34;
            gout39 += g_4 * g_24 * g_35;
            gout40 += g_3 * g_28 * g_32;
            gout41 += g_2 * g_29 * g_32;
            gout42 += g_2 * g_28 * g_33;
            gout43 += g_1 * g_30 * g_32;
            gout44 += g_1 * g_29 * g_33;
            gout45 += g_1 * g_28 * g_34;
            gout46 += g_0 * g_31 * g_32;
            gout47 += g_0 * g_30 * g_33;
            gout48 += g_0 * g_29 * g_34;
            gout49 += g_0 * g_28 * g_35;
            gout50 += g_3 * g_24 * g_36;
            gout51 += g_2 * g_25 * g_36;
            gout52 += g_2 * g_24 * g_37;
            gout53 += g_1 * g_26 * g_36;
            gout54 += g_1 * g_25 * g_37;
            gout55 += g_1 * g_24 * g_38;
            gout56 += g_0 * g_27 * g_36;
            gout57 += g_0 * g_26 * g_37;
            gout58 += g_0 * g_25 * g_38;
            gout59 += g_0 * g_24 * g_39;
            gout60 += g_7 * g_16 * g_40;
            gout61 += g_6 * g_17 * g_40;
            gout62 += g_6 * g_16 * g_41;
            gout63 += g_5 * g_18 * g_40;
            gout64 += g_5 * g_17 * g_41;
            gout65 += g_5 * g_16 * g_42;
            gout66 += g_4 * g_19 * g_40;
            gout67 += g_4 * g_18 * g_41;
            gout68 += g_4 * g_17 * g_42;
            gout69 += g_4 * g_16 * g_43;
            gout70 += g_3 * g_20 * g_40;
            gout71 += g_2 * g_21 * g_40;
            gout72 += g_2 * g_20 * g_41;
            gout73 += g_1 * g_22 * g_40;
            gout74 += g_1 * g_21 * g_41;
            gout75 += g_1 * g_20 * g_42;
            gout76 += g_0 * g_23 * g_40;
            gout77 += g_0 * g_22 * g_41;
            gout78 += g_0 * g_21 * g_42;
            gout79 += g_0 * g_20 * g_43;
            gout80 += g_3 * g_16 * g_44;
            gout81 += g_2 * g_17 * g_44;
            gout82 += g_2 * g_16 * g_45;
            gout83 += g_1 * g_18 * g_44;
            gout84 += g_1 * g_17 * g_45;
            gout85 += g_1 * g_16 * g_46;
            gout86 += g_0 * g_19 * g_44;
            gout87 += g_0 * g_18 * g_45;
            gout88 += g_0 * g_17 * g_46;
            gout89 += g_0 * g_16 * g_47;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[3] = gout3;
    //eri_ji[3*jstride] = gout3;
    eri_ij[4] = gout4;
    //eri_ji[4*jstride] = gout4;
    eri_ij[5] = gout5;
    //eri_ji[5*jstride] = gout5;
    eri_ij[6] = gout6;
    //eri_ji[6*jstride] = gout6;
    eri_ij[7] = gout7;
    //eri_ji[7*jstride] = gout7;
    eri_ij[8] = gout8;
    //eri_ji[8*jstride] = gout8;
    eri_ij[9] = gout9;
    //eri_ji[9*jstride] = gout9;
    eri_ij[1*jstride] = gout10;
    //eri_ji[1] = gout10;
    eri_ij[1+1*jstride] = gout11;
    //eri_ji[1*jstride+1] = gout11;
    eri_ij[2+1*jstride] = gout12;
    //eri_ji[2*jstride+1] = gout12;
    eri_ij[3+1*jstride] = gout13;
    //eri_ji[3*jstride+1] = gout13;
    eri_ij[4+1*jstride] = gout14;
    //eri_ji[4*jstride+1] = gout14;
    eri_ij[5+1*jstride] = gout15;
    //eri_ji[5*jstride+1] = gout15;
    eri_ij[6+1*jstride] = gout16;
    //eri_ji[6*jstride+1] = gout16;
    eri_ij[7+1*jstride] = gout17;
    //eri_ji[7*jstride+1] = gout17;
    eri_ij[8+1*jstride] = gout18;
    //eri_ji[8*jstride+1] = gout18;
    eri_ij[9+1*jstride] = gout19;
    //eri_ji[9*jstride+1] = gout19;
    eri_ij[2*jstride] = gout20;
    //eri_ji[2] = gout20;
    eri_ij[1+2*jstride] = gout21;
    //eri_ji[1*jstride+2] = gout21;
    eri_ij[2+2*jstride] = gout22;
    //eri_ji[2*jstride+2] = gout22;
    eri_ij[3+2*jstride] = gout23;
    //eri_ji[3*jstride+2] = gout23;
    eri_ij[4+2*jstride] = gout24;
    //eri_ji[4*jstride+2] = gout24;
    eri_ij[5+2*jstride] = gout25;
    //eri_ji[5*jstride+2] = gout25;
    eri_ij[6+2*jstride] = gout26;
    //eri_ji[6*jstride+2] = gout26;
    eri_ij[7+2*jstride] = gout27;
    //eri_ji[7*jstride+2] = gout27;
    eri_ij[8+2*jstride] = gout28;
    //eri_ji[8*jstride+2] = gout28;
    eri_ij[9+2*jstride] = gout29;
    //eri_ji[9*jstride+2] = gout29;
    eri_ij[1*kstride] = gout30;
    //eri_ji[1*kstride] = gout30;
    eri_ij[1+1*kstride] = gout31;
    //eri_ji[1*jstride+1*kstride] = gout31;
    eri_ij[2+1*kstride] = gout32;
    //eri_ji[2*jstride+1*kstride] = gout32;
    eri_ij[3+1*kstride] = gout33;
    //eri_ji[3*jstride+1*kstride] = gout33;
    eri_ij[4+1*kstride] = gout34;
    //eri_ji[4*jstride+1*kstride] = gout34;
    eri_ij[5+1*kstride] = gout35;
    //eri_ji[5*jstride+1*kstride] = gout35;
    eri_ij[6+1*kstride] = gout36;
    //eri_ji[6*jstride+1*kstride] = gout36;
    eri_ij[7+1*kstride] = gout37;
    //eri_ji[7*jstride+1*kstride] = gout37;
    eri_ij[8+1*kstride] = gout38;
    //eri_ji[8*jstride+1*kstride] = gout38;
    eri_ij[9+1*kstride] = gout39;
    //eri_ji[9*jstride+1*kstride] = gout39;
    eri_ij[1*jstride+1*kstride] = gout40;
    //eri_ji[1+1*kstride] = gout40;
    eri_ij[1+1*jstride+1*kstride] = gout41;
    //eri_ji[1*jstride+1+1*kstride] = gout41;
    eri_ij[2+1*jstride+1*kstride] = gout42;
    //eri_ji[2*jstride+1+1*kstride] = gout42;
    eri_ij[3+1*jstride+1*kstride] = gout43;
    //eri_ji[3*jstride+1+1*kstride] = gout43;
    eri_ij[4+1*jstride+1*kstride] = gout44;
    //eri_ji[4*jstride+1+1*kstride] = gout44;
    eri_ij[5+1*jstride+1*kstride] = gout45;
    //eri_ji[5*jstride+1+1*kstride] = gout45;
    eri_ij[6+1*jstride+1*kstride] = gout46;
    //eri_ji[6*jstride+1+1*kstride] = gout46;
    eri_ij[7+1*jstride+1*kstride] = gout47;
    //eri_ji[7*jstride+1+1*kstride] = gout47;
    eri_ij[8+1*jstride+1*kstride] = gout48;
    //eri_ji[8*jstride+1+1*kstride] = gout48;
    eri_ij[9+1*jstride+1*kstride] = gout49;
    //eri_ji[9*jstride+1+1*kstride] = gout49;
    eri_ij[2*jstride+1*kstride] = gout50;
    //eri_ji[2+1*kstride] = gout50;
    eri_ij[1+2*jstride+1*kstride] = gout51;
    //eri_ji[1*jstride+2+1*kstride] = gout51;
    eri_ij[2+2*jstride+1*kstride] = gout52;
    //eri_ji[2*jstride+2+1*kstride] = gout52;
    eri_ij[3+2*jstride+1*kstride] = gout53;
    //eri_ji[3*jstride+2+1*kstride] = gout53;
    eri_ij[4+2*jstride+1*kstride] = gout54;
    //eri_ji[4*jstride+2+1*kstride] = gout54;
    eri_ij[5+2*jstride+1*kstride] = gout55;
    //eri_ji[5*jstride+2+1*kstride] = gout55;
    eri_ij[6+2*jstride+1*kstride] = gout56;
    //eri_ji[6*jstride+2+1*kstride] = gout56;
    eri_ij[7+2*jstride+1*kstride] = gout57;
    //eri_ji[7*jstride+2+1*kstride] = gout57;
    eri_ij[8+2*jstride+1*kstride] = gout58;
    //eri_ji[8*jstride+2+1*kstride] = gout58;
    eri_ij[9+2*jstride+1*kstride] = gout59;
    //eri_ji[9*jstride+2+1*kstride] = gout59;
    eri_ij[2*kstride] = gout60;
    //eri_ji[2*kstride] = gout60;
    eri_ij[1+2*kstride] = gout61;
    //eri_ji[1*jstride+2*kstride] = gout61;
    eri_ij[2+2*kstride] = gout62;
    //eri_ji[2*jstride+2*kstride] = gout62;
    eri_ij[3+2*kstride] = gout63;
    //eri_ji[3*jstride+2*kstride] = gout63;
    eri_ij[4+2*kstride] = gout64;
    //eri_ji[4*jstride+2*kstride] = gout64;
    eri_ij[5+2*kstride] = gout65;
    //eri_ji[5*jstride+2*kstride] = gout65;
    eri_ij[6+2*kstride] = gout66;
    //eri_ji[6*jstride+2*kstride] = gout66;
    eri_ij[7+2*kstride] = gout67;
    //eri_ji[7*jstride+2*kstride] = gout67;
    eri_ij[8+2*kstride] = gout68;
    //eri_ji[8*jstride+2*kstride] = gout68;
    eri_ij[9+2*kstride] = gout69;
    //eri_ji[9*jstride+2*kstride] = gout69;
    eri_ij[1*jstride+2*kstride] = gout70;
    //eri_ji[1+2*kstride] = gout70;
    eri_ij[1+1*jstride+2*kstride] = gout71;
    //eri_ji[1*jstride+1+2*kstride] = gout71;
    eri_ij[2+1*jstride+2*kstride] = gout72;
    //eri_ji[2*jstride+1+2*kstride] = gout72;
    eri_ij[3+1*jstride+2*kstride] = gout73;
    //eri_ji[3*jstride+1+2*kstride] = gout73;
    eri_ij[4+1*jstride+2*kstride] = gout74;
    //eri_ji[4*jstride+1+2*kstride] = gout74;
    eri_ij[5+1*jstride+2*kstride] = gout75;
    //eri_ji[5*jstride+1+2*kstride] = gout75;
    eri_ij[6+1*jstride+2*kstride] = gout76;
    //eri_ji[6*jstride+1+2*kstride] = gout76;
    eri_ij[7+1*jstride+2*kstride] = gout77;
    //eri_ji[7*jstride+1+2*kstride] = gout77;
    eri_ij[8+1*jstride+2*kstride] = gout78;
    //eri_ji[8*jstride+1+2*kstride] = gout78;
    eri_ij[9+1*jstride+2*kstride] = gout79;
    //eri_ji[9*jstride+1+2*kstride] = gout79;
    eri_ij[2*jstride+2*kstride] = gout80;
    //eri_ji[2+2*kstride] = gout80;
    eri_ij[1+2*jstride+2*kstride] = gout81;
    //eri_ji[1*jstride+2+2*kstride] = gout81;
    eri_ij[2+2*jstride+2*kstride] = gout82;
    //eri_ji[2*jstride+2+2*kstride] = gout82;
    eri_ij[3+2*jstride+2*kstride] = gout83;
    //eri_ji[3*jstride+2+2*kstride] = gout83;
    eri_ij[4+2*jstride+2*kstride] = gout84;
    //eri_ji[4*jstride+2+2*kstride] = gout84;
    eri_ij[5+2*jstride+2*kstride] = gout85;
    //eri_ji[5*jstride+2+2*kstride] = gout85;
    eri_ij[6+2*jstride+2*kstride] = gout86;
    //eri_ji[6*jstride+2+2*kstride] = gout86;
    eri_ij[7+2*jstride+2*kstride] = gout87;
    //eri_ji[7*jstride+2+2*kstride] = gout87;
    eri_ij[8+2*jstride+2*kstride] = gout88;
    //eri_ji[8*jstride+2+2*kstride] = gout88;
    eri_ij[9+2*jstride+2*kstride] = gout89;
    //eri_ji[9*jstride+2+2*kstride] = gout89;
}

__global__
static void GINTfill_int2e_kernel3200(GINTEnvVars envs, ERITensor eri, BasisProdOffsets offsets)
{
    int ntasks_ij = offsets.ntasks_ij;
    int ntasks_kl = offsets.ntasks_kl;
    int task_ij = blockIdx.x * blockDim.x + threadIdx.x;
    int task_kl = blockIdx.y * blockDim.y + threadIdx.y;
    if (task_ij >= ntasks_ij || task_kl >= ntasks_kl) {
        return;
    }
    int bas_ij = offsets.bas_ij + task_ij;
    int bas_kl = offsets.bas_kl + task_kl;
    double norm = envs.fac;
    double omega = envs.omega;
    int *bas_pair2bra = c_bpcache.bas_pair2bra;
    int *bas_pair2ket = c_bpcache.bas_pair2ket;
    int ish = bas_pair2bra[bas_ij];
    int jsh = bas_pair2ket[bas_ij];
    int ksh = bas_pair2bra[bas_kl];
    int lsh = bas_pair2ket[bas_kl];
    int nprim_ij = envs.nprim_ij;
    int nprim_kl = envs.nprim_kl;
    int prim_ij = offsets.primitive_ij + task_ij * nprim_ij;
    int prim_kl = offsets.primitive_kl + task_kl * nprim_kl;
    double* __restrict__ a12 = c_bpcache.a12;
    double* __restrict__ e12 = c_bpcache.e12;
    double* __restrict__ x12 = c_bpcache.x12;
    double* __restrict__ y12 = c_bpcache.y12;
    double* __restrict__ z12 = c_bpcache.z12;
    int ij, kl;
    int prim_ij0, prim_ij1, prim_kl0, prim_kl1;
    int nbas = c_bpcache.nbas;
    double* __restrict__ bas_x = c_bpcache.bas_coords;
    double* __restrict__ bas_y = bas_x + nbas;
    double* __restrict__ bas_z = bas_y + nbas;

    double gout0 = 0;
    double gout1 = 0;
    double gout2 = 0;
    double gout3 = 0;
    double gout4 = 0;
    double gout5 = 0;
    double gout6 = 0;
    double gout7 = 0;
    double gout8 = 0;
    double gout9 = 0;
    double gout10 = 0;
    double gout11 = 0;
    double gout12 = 0;
    double gout13 = 0;
    double gout14 = 0;
    double gout15 = 0;
    double gout16 = 0;
    double gout17 = 0;
    double gout18 = 0;
    double gout19 = 0;
    double gout20 = 0;
    double gout21 = 0;
    double gout22 = 0;
    double gout23 = 0;
    double gout24 = 0;
    double gout25 = 0;
    double gout26 = 0;
    double gout27 = 0;
    double gout28 = 0;
    double gout29 = 0;
    double gout30 = 0;
    double gout31 = 0;
    double gout32 = 0;
    double gout33 = 0;
    double gout34 = 0;
    double gout35 = 0;
    double gout36 = 0;
    double gout37 = 0;
    double gout38 = 0;
    double gout39 = 0;
    double gout40 = 0;
    double gout41 = 0;
    double gout42 = 0;
    double gout43 = 0;
    double gout44 = 0;
    double gout45 = 0;
    double gout46 = 0;
    double gout47 = 0;
    double gout48 = 0;
    double gout49 = 0;
    double gout50 = 0;
    double gout51 = 0;
    double gout52 = 0;
    double gout53 = 0;
    double gout54 = 0;
    double gout55 = 0;
    double gout56 = 0;
    double gout57 = 0;
    double gout58 = 0;
    double gout59 = 0;
    double xi = bas_x[ish];
    double yi = bas_y[ish];
    double zi = bas_z[ish];
    double xixj = xi - bas_x[jsh];
    double yiyj = yi - bas_y[jsh];
    double zizj = zi - bas_z[jsh];
    prim_ij0 = prim_ij;
    prim_ij1 = prim_ij + nprim_ij;
    prim_kl0 = prim_kl;
    prim_kl1 = prim_kl + nprim_kl;
    for (ij = prim_ij0; ij < prim_ij1; ++ij) {
    for (kl = prim_kl0; kl < prim_kl1; ++kl) {
        double aij = a12[ij];
        double eij = e12[ij];
        double xij = x12[ij];
        double yij = y12[ij];
        double zij = z12[ij];
        double akl = a12[kl];
        double ekl = e12[kl];
        double xkl = x12[kl];
        double ykl = y12[kl];
        double zkl = z12[kl];
        double xijxkl = xij - xkl;
        double yijykl = yij - ykl;
        double zijzkl = zij - zkl;
        double aijkl = aij + akl;
        double a1 = aij * akl;
        double a0 = a1 / aijkl;
        double theta = omega > 0.0 ? omega * omega / (omega * omega + a0) : 1.0; 
        a0 *= theta;
        double x = a0 * (xijxkl * xijxkl + yijykl * yijykl + zijzkl * zijzkl);
        double fac = norm * eij * ekl * sqrt(a0 / (a1 * a1 * a1));
        //double fac = norm * eij * ekl / (sqrt(aijkl) * a1);

        double rw[6];
        double root0, weight0;
        GINTrys_root<3>(x, rw);
        GINTscale_u<3>(rw, theta);
        int irys;
        for (irys = 0; irys < 3; ++irys) {
            root0 = rw[irys];
            weight0 = rw[irys+3];
            double u2 = a0 * root0;
            double tmp4 = .5 / (u2 * aijkl + a1);
            double b00 = u2 * tmp4;
            double tmp1 = 2 * b00;
            double tmp2 = tmp1 * akl;
            double b10 = b00 + tmp4 * akl;
            double c00x = xij - xi - tmp2 * xijxkl;
            double c00y = yij - yi - tmp2 * yijykl;
            double c00z = zij - zi - tmp2 * zijzkl;
            double g_0 = 1;
            double g_1 = c00x;
            double g_2 = c00x * c00x + b10;
            double g_3 = c00x * (2 * b10 + g_2);
            double g_4 = c00x + xixj;
            double g_5 = c00x * (c00x + xixj) + b10;
            double g_6 = c00x * (2 * b10 + g_2) + xixj * g_2;
            double g_7 = 3 * b10 * g_2 + c00x * g_3 + xixj * g_3;
            double g_8 = xixj * (xixj + c00x) + xixj * c00x + c00x * c00x + b10;
            double g_9 = xixj * (xixj * c00x + c00x * c00x + b10) + xixj * g_2 + c00x * g_2 + 2 * b10 * c00x;
            double g_10 = xixj * (xixj * g_2 + c00x * g_2 + 2 * b10 * c00x) + xixj * g_3 + c00x * g_3 + 3 * b10 * g_2;
            double g_11 = xixj * (xixj * g_3 + c00x * g_3 + 3 * b10 * g_2) + xixj * (c00x * g_3 + 3 * b10 * g_2) + c00x * (c00x * g_3 + 3 * b10 * g_2) + 4 * b10 * g_3;
            double g_12 = 1;
            double g_13 = c00y;
            double g_14 = c00y * c00y + b10;
            double g_15 = c00y * (2 * b10 + g_14);
            double g_16 = c00y + yiyj;
            double g_17 = c00y * (c00y + yiyj) + b10;
            double g_18 = c00y * (2 * b10 + g_14) + yiyj * g_14;
            double g_19 = 3 * b10 * g_14 + c00y * g_15 + yiyj * g_15;
            double g_20 = yiyj * (yiyj + c00y) + yiyj * c00y + c00y * c00y + b10;
            double g_21 = yiyj * (yiyj * c00y + c00y * c00y + b10) + yiyj * g_14 + c00y * g_14 + 2 * b10 * c00y;
            double g_22 = yiyj * (yiyj * g_14 + c00y * g_14 + 2 * b10 * c00y) + yiyj * g_15 + c00y * g_15 + 3 * b10 * g_14;
            double g_23 = yiyj * (yiyj * g_15 + c00y * g_15 + 3 * b10 * g_14) + yiyj * (c00y * g_15 + 3 * b10 * g_14) + c00y * (c00y * g_15 + 3 * b10 * g_14) + 4 * b10 * g_15;
            double g_24 = weight0 * fac;
            double g_25 = c00z * g_24;
            double g_26 = b10 * g_24 + c00z * g_25;
            double g_27 = 2 * b10 * g_25 + c00z * g_26;
            double g_28 = g_24 * (c00z + zizj);
            double g_29 = b10 * g_24 + c00z * g_25 + zizj * g_25;
            double g_30 = 2 * b10 * g_25 + c00z * g_26 + zizj * g_26;
            double g_31 = 3 * b10 * g_26 + c00z * g_27 + zizj * g_27;
            double g_32 = zizj * (zizj * g_24 + c00z * g_24) + zizj * g_25 + c00z * g_25 + b10 * g_24;
            double g_33 = zizj * (zizj * g_25 + c00z * g_25 + b10 * g_24) + zizj * g_26 + c00z * g_26 + 2 * b10 * g_25;
            double g_34 = zizj * (zizj * g_26 + c00z * g_26 + 2 * b10 * g_25) + zizj * g_27 + c00z * g_27 + 3 * b10 * g_26;
            double g_35 = zizj * (zizj * g_27 + c00z * g_27 + 3 * b10 * g_26) + zizj * (c00z * g_27 + 3 * b10 * g_26) + c00z * (c00z * g_27 + 3 * b10 * g_26) + 4 * b10 * g_27;
            gout0 += g_11 * g_12 * g_24;
            gout1 += g_10 * g_13 * g_24;
            gout2 += g_10 * g_12 * g_25;
            gout3 += g_9 * g_14 * g_24;
            gout4 += g_9 * g_13 * g_25;
            gout5 += g_9 * g_12 * g_26;
            gout6 += g_8 * g_15 * g_24;
            gout7 += g_8 * g_14 * g_25;
            gout8 += g_8 * g_13 * g_26;
            gout9 += g_8 * g_12 * g_27;
            gout10 += g_7 * g_16 * g_24;
            gout11 += g_6 * g_17 * g_24;
            gout12 += g_6 * g_16 * g_25;
            gout13 += g_5 * g_18 * g_24;
            gout14 += g_5 * g_17 * g_25;
            gout15 += g_5 * g_16 * g_26;
            gout16 += g_4 * g_19 * g_24;
            gout17 += g_4 * g_18 * g_25;
            gout18 += g_4 * g_17 * g_26;
            gout19 += g_4 * g_16 * g_27;
            gout20 += g_7 * g_12 * g_28;
            gout21 += g_6 * g_13 * g_28;
            gout22 += g_6 * g_12 * g_29;
            gout23 += g_5 * g_14 * g_28;
            gout24 += g_5 * g_13 * g_29;
            gout25 += g_5 * g_12 * g_30;
            gout26 += g_4 * g_15 * g_28;
            gout27 += g_4 * g_14 * g_29;
            gout28 += g_4 * g_13 * g_30;
            gout29 += g_4 * g_12 * g_31;
            gout30 += g_3 * g_20 * g_24;
            gout31 += g_2 * g_21 * g_24;
            gout32 += g_2 * g_20 * g_25;
            gout33 += g_1 * g_22 * g_24;
            gout34 += g_1 * g_21 * g_25;
            gout35 += g_1 * g_20 * g_26;
            gout36 += g_0 * g_23 * g_24;
            gout37 += g_0 * g_22 * g_25;
            gout38 += g_0 * g_21 * g_26;
            gout39 += g_0 * g_20 * g_27;
            gout40 += g_3 * g_16 * g_28;
            gout41 += g_2 * g_17 * g_28;
            gout42 += g_2 * g_16 * g_29;
            gout43 += g_1 * g_18 * g_28;
            gout44 += g_1 * g_17 * g_29;
            gout45 += g_1 * g_16 * g_30;
            gout46 += g_0 * g_19 * g_28;
            gout47 += g_0 * g_18 * g_29;
            gout48 += g_0 * g_17 * g_30;
            gout49 += g_0 * g_16 * g_31;
            gout50 += g_3 * g_12 * g_32;
            gout51 += g_2 * g_13 * g_32;
            gout52 += g_2 * g_12 * g_33;
            gout53 += g_1 * g_14 * g_32;
            gout54 += g_1 * g_13 * g_33;
            gout55 += g_1 * g_12 * g_34;
            gout56 += g_0 * g_15 * g_32;
            gout57 += g_0 * g_14 * g_33;
            gout58 += g_0 * g_13 * g_34;
            gout59 += g_0 * g_12 * g_35;
        }
    } }

    int jstride = eri.stride_j;
    int kstride = eri.stride_k;
    int lstride = eri.stride_l;
    int *ao_loc = c_bpcache.ao_loc;
    int i0 = ao_loc[ish] - eri.ao_offsets_i;
    int j0 = ao_loc[jsh] - eri.ao_offsets_j;
    int k0 = ao_loc[ksh] - eri.ao_offsets_k;
    int l0 = ao_loc[lsh] - eri.ao_offsets_l;
    double* __restrict__ eri_ij = eri.data + l0*lstride+k0*kstride+j0*jstride+i0;
    //double* __restrict__ eri_ji = eri.data + l0*lstride+k0*kstride+i0*jstride+j0;
    eri_ij[0] = gout0;
    //eri_ji[0] = gout0;
    eri_ij[1] = gout1;
    //eri_ji[1*jstride] = gout1;
    eri_ij[2] = gout2;
    //eri_ji[2*jstride] = gout2;
    eri_ij[3] = gout3;
    //eri_ji[3*jstride] = gout3;
    eri_ij[4] = gout4;
    //eri_ji[4*jstride] = gout4;
    eri_ij[5] = gout5;
    //eri_ji[5*jstride] = gout5;
    eri_ij[6] = gout6;
    //eri_ji[6*jstride] = gout6;
    eri_ij[7] = gout7;
    //eri_ji[7*jstride] = gout7;
    eri_ij[8] = gout8;
    //eri_ji[8*jstride] = gout8;
    eri_ij[9] = gout9;
    //eri_ji[9*jstride] = gout9;
    eri_ij[1*jstride] = gout10;
    //eri_ji[1] = gout10;
    eri_ij[1+1*jstride] = gout11;
    //eri_ji[1*jstride+1] = gout11;
    eri_ij[2+1*jstride] = gout12;
    //eri_ji[2*jstride+1] = gout12;
    eri_ij[3+1*jstride] = gout13;
    //eri_ji[3*jstride+1] = gout13;
    eri_ij[4+1*jstride] = gout14;
    //eri_ji[4*jstride+1] = gout14;
    eri_ij[5+1*jstride] = gout15;
    //eri_ji[5*jstride+1] = gout15;
    eri_ij[6+1*jstride] = gout16;
    //eri_ji[6*jstride+1] = gout16;
    eri_ij[7+1*jstride] = gout17;
    //eri_ji[7*jstride+1] = gout17;
    eri_ij[8+1*jstride] = gout18;
    //eri_ji[8*jstride+1] = gout18;
    eri_ij[9+1*jstride] = gout19;
    //eri_ji[9*jstride+1] = gout19;
    eri_ij[2*jstride] = gout20;
    //eri_ji[2] = gout20;
    eri_ij[1+2*jstride] = gout21;
    //eri_ji[1*jstride+2] = gout21;
    eri_ij[2+2*jstride] = gout22;
    //eri_ji[2*jstride+2] = gout22;
    eri_ij[3+2*jstride] = gout23;
    //eri_ji[3*jstride+2] = gout23;
    eri_ij[4+2*jstride] = gout24;
    //eri_ji[4*jstride+2] = gout24;
    eri_ij[5+2*jstride] = gout25;
    //eri_ji[5*jstride+2] = gout25;
    eri_ij[6+2*jstride] = gout26;
    //eri_ji[6*jstride+2] = gout26;
    eri_ij[7+2*jstride] = gout27;
    //eri_ji[7*jstride+2] = gout27;
    eri_ij[8+2*jstride] = gout28;
    //eri_ji[8*jstride+2] = gout28;
    eri_ij[9+2*jstride] = gout29;
    //eri_ji[9*jstride+2] = gout29;
    eri_ij[3*jstride] = gout30;
    //eri_ji[3] = gout30;
    eri_ij[1+3*jstride] = gout31;
    //eri_ji[1*jstride+3] = gout31;
    eri_ij[2+3*jstride] = gout32;
    //eri_ji[2*jstride+3] = gout32;
    eri_ij[3+3*jstride] = gout33;
    //eri_ji[3*jstride+3] = gout33;
    eri_ij[4+3*jstride] = gout34;
    //eri_ji[4*jstride+3] = gout34;
    eri_ij[5+3*jstride] = gout35;
    //eri_ji[5*jstride+3] = gout35;
    eri_ij[6+3*jstride] = gout36;
    //eri_ji[6*jstride+3] = gout36;
    eri_ij[7+3*jstride] = gout37;
    //eri_ji[7*jstride+3] = gout37;
    eri_ij[8+3*jstride] = gout38;
    //eri_ji[8*jstride+3] = gout38;
    eri_ij[9+3*jstride] = gout39;
    //eri_ji[9*jstride+3] = gout39;
    eri_ij[4*jstride] = gout40;
    //eri_ji[4] = gout40;
    eri_ij[1+4*jstride] = gout41;
    //eri_ji[1*jstride+4] = gout41;
    eri_ij[2+4*jstride] = gout42;
    //eri_ji[2*jstride+4] = gout42;
    eri_ij[3+4*jstride] = gout43;
    //eri_ji[3*jstride+4] = gout43;
    eri_ij[4+4*jstride] = gout44;
    //eri_ji[4*jstride+4] = gout44;
    eri_ij[5+4*jstride] = gout45;
    //eri_ji[5*jstride+4] = gout45;
    eri_ij[6+4*jstride] = gout46;
    //eri_ji[6*jstride+4] = gout46;
    eri_ij[7+4*jstride] = gout47;
    //eri_ji[7*jstride+4] = gout47;
    eri_ij[8+4*jstride] = gout48;
    //eri_ji[8*jstride+4] = gout48;
    eri_ij[9+4*jstride] = gout49;
    //eri_ji[9*jstride+4] = gout49;
    eri_ij[5*jstride] = gout50;
    //eri_ji[5] = gout50;
    eri_ij[1+5*jstride] = gout51;
    //eri_ji[1*jstride+5] = gout51;
    eri_ij[2+5*jstride] = gout52;
    //eri_ji[2*jstride+5] = gout52;
    eri_ij[3+5*jstride] = gout53;
    //eri_ji[3*jstride+5] = gout53;
    eri_ij[4+5*jstride] = gout54;
    //eri_ji[4*jstride+5] = gout54;
    eri_ij[5+5*jstride] = gout55;
    //eri_ji[5*jstride+5] = gout55;
    eri_ij[6+5*jstride] = gout56;
    //eri_ji[6*jstride+5] = gout56;
    eri_ij[7+5*jstride] = gout57;
    //eri_ji[7*jstride+5] = gout57;
    eri_ij[8+5*jstride] = gout58;
    //eri_ji[8*jstride+5] = gout58;
    eri_ij[9+5*jstride] = gout59;
    //eri_ji[9*jstride+5] = gout59;
}

